2022-9-2 作业

第一题与第二题:

  1 #include
  2 #include
  3 int main(int argc, const char *argv[])
  4 {
  5 
  6     int size = 3;
  7     char a[size];
  8     gets(a);
  9     puts(a);
 10 
 11     printf("%d\n",printf("%s\n",a));
 12     printf("%s\n",a);
 13     printf("-------\n");
 14     int i,j,count;
 15     i = 0;count = 0;
 16     while(i

第三题:-------------------------

  1 #include 
  2 
  3 int main(int argc, const char *argv[])
  4 {
  5     char a[] = "ccccc";
  6     char b[] = "bb";
  7 
  8     int i=0,c;                       //strcmp
  9     while(a[i]!='\0'&&b[i]!='\0')
 10     {
 11         if(a[i]!=b[i])
 12         {
 13             c = a[i] - b[i];
 14             break;
 15         }
 16         i++;
 17     }
 18     if(a[i]=='\0'||b[i]=='\0')
 19     {
 20         c = a[i] - -b[i];
 21     }
 22     printf("strcmp = %d\n",c);
 23     puts(a);
 24     puts(b);
 25     printf("%ld\n",sizeof(a)/sizeof(char));
 26                                               //strcat  
 27     int size_ab = (sizeof(a) + sizeof(b))/sizeof(char)-1;
 28     char ab[size_ab];
 29     for(i = 0;i=sizeof(a)/sizeof(char)-2 && i

你可能感兴趣的:(c语言)