我想将一些字符串保存在字符串矩阵中。问题是我收到此错误:段错误核心已转储。我在互联网上进行了研究,但没有任何示例说明如何将 ssscanf 与字符串矩阵一起使用。
char * b[20][4];
sscanf("one two three","%s %s %s",b[0][0], b[0][1],b[0][2]);
printf("%s %s %s",b[0][0], b[0][1],b[0][2]);
最佳答案
尝试:
char b[20][8]; // three has five characters, lose the * to allocate memory
sscanf("one two three","%s %s %s",b[0], b[1],b[2]);
printf("%s %s %s\n",b[0], b[1],b[2]);
关于c - 如何在c中将ssscanf与字符串矩阵一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20356331/