#include <stdio.h>#include <string.h>int main()
{ char a[10000];
char b[10000];
printf ("请输入两个字符串:");
while(1){
putchar(a[0]); }
//scanf("%s\n");
printf ("%s",a[0]) ;
return 0;}上面的代码执行出来。。是永远在输入,没有输出。。感觉字符串的操作很麻烦。。摸索到现在还是不太会。。再如以下的也有点奇怪的感觉
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char line[] = "hello,my name is xx\n";
printf("%s",line);
char *copy = (char*)malloc(strlen(line)+1);
strcpy(copy,line);
copy[strlen(line)] = '\0' ;
//printf("%s\n",*copy); printf("%s\n",copy);
return 0;}问题在于。。。上面的代码最后一行为什么printf后面的copy不用加*呢?同样是运用指针,如果我用来操作打印int型变量就一定是要加*的,不然打印出来是地址。。但是字符串又不一样。。。求各位大佬慷慨解释一下
慕姐6162487
慕盖茨9781818
随时随地看视频慕课网APP