11、
12、
13、
14、
15、
代码:
1 #pragma warning(disable:4996) 2 #pragma warning(disable:6031) 3 #include <stdio.h> 4 #include <string.h> 5 6 void strpy(char* str1,char* str2) { 7 while (*str2!='\0') 8 { 9 *str1 = *str2; 10 str1++; 11 str2++; 12 } 13 *str1 = '\0'; 14 } 15 16 int main() { 17 char str1[100]; 18 char str2[100]; 19 scanf("%s", str1); 20 scanf("%s", str2); 21 strpy(str1, str2); 22 printf("复制后:\nstr1:%s\tstr2:%s\n",str1,str2); 23 return 0; 24 }View Code
结果:
16、
17、
18、
代码:
1 #pragma warning(disable:4996) 2 #pragma warning(disable:6031) 3 #include <stdio.h> 4 #include <string.h> 5 6 void reverse(char* str) { 7 char* front = str; 8 int len = 0; 9 while (*front != '\0') { 10 len++; 11 front++; 12 } 13 char* tail = str + len - 1; 14 front = str; 15 while (front <= tail) { 16 char temp = *front; 17 *front = *tail; 18 *tail = temp; 19 front++; 20 tail--; 21 } 22 } 23 24 int main() { 25 char str[100]; 26 scanf("%s", str); 27 reverse(str); 28 printf("转换后:%s\n", str); 29 return 0; 30 }View Code
结果:
19、
20、
标签:11,20,str2,str1,char,warning,front From: https://www.cnblogs.com/kezhang/p/16714998.html