Creating one array of strings in c fails ,why?

Error code:

#include<stdio.h>

#include<string.h>

#include<ctype.h>

#include<stdlib.h>

int main(void)

{

char *foo[100];//array of pointer

strcpy(f00[0],”测试");

printf(“%s”,foo[0]);

return 1;

}

问题:

分配了一个指针数组,如果需要分配各字符串给第一个指针,需要分配空间给特定的指针然后再赋值。

将foo[0]=malloc(13);//用完释放

strcpy(foo[0],”test file”);

例子二:

char foo[10][100]={0};

strcpy(foo[0],”test”);

strcpy_s(foo[0],100,”test”);

posted @ 2011-12-30 16:19  lxk613  阅读(115)  评论(0编辑  收藏  举报