关于字符串的问题
为什么下面代码无法实现把两个字符串拼接呢?#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char a = "abcde";
char b = "fghjk";
char *aa = a;
char *bb = b;
while (*aa != '\0')
{
aa++;
}
while (*bb != '\0')
{
*aa++ = *bb++;
}
*aa = '\0';
puts(aa);
putchar('\n');
system("pause");
return 0;
} 再看看第18行想一想? #include <stdio.h>
#include <stdlib.h>
int main(void)
{
char a = "abcde";
char b = "fghjk";
char *aa = a;
char *bb = b;
while (*aa != '\0')
{
aa++;
}
while (*bb != '\0')
{
*aa++ = *bb++;
}
*aa = '\0';
puts(a); // 这里应该是输出字符串 a
putchar('\n');
system("pause");
return 0;
} 厉害{:5_106:}
页:
[1]