ch = *target2++ = *target1++怎么理解
#include"stdio.h"#include"string.h"
int main()
{
int i,ch;
char str1, str2;
char *target1 = str1, *target2 = str2;
printf("请输入一个字符串到str1中:");
fgets(str1, 1024, stdin);
printf("要拷贝的字符个数:");
scanf_s("%d", &i);
printf("\n开始拷贝,str1的内容到str2中……\n");
while (i--)
{
ch = *target2++ = *target1++;
if (ch == '\0')
{
break;
}
if ((int)ch < 0)
{
ch =*target2++ = *target1++;
}
strncpy(str2, str1, 1);
}
*target2 = '\0';
printf("拷贝完毕!现在,str2中的内容是:%s", str2);
return 0;
} ch = *target1;
*target2 = *target1;
target1++;
target2++; lhgzbxhz 发表于 2021-11-21 16:26
感谢
页:
[1]