0
我试图在一个声明为char *name[2];
的变量中存储一个字符串。我正在使用scanf()
从用户输入中获取值。这是到目前为止我的代码和其目前没有工作:如何将字符串存储在C中的char * s []中?
#include <stdio.h>
#include <stdlib.h>
int main()
{ char *name[2];
scanf("%s",name[0]);
printf("%s",name[0]);
return 0;
}
另请参阅:http://stackoverflow.com/questions/1704407/what-is-the-difference-between-char-s-and-char-s-in-c – Lundin