gpt4 book ai didi

c - 如何在c中将ssscanf与字符串矩阵一起使用

转载 作者:行者123 更新时间:2023-11-30 15:42:02 26 4
gpt4 key购买 nike

我想将一些字符串保存在字符串矩阵中。问题是我收到此错误:段错误核心已转储。我在互联网上进行了研究,但没有任何示例说明如何将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com