gpt4 book ai didi

c - 从文本文件读入数组并使用 C 编程语言

转载 作者:行者123 更新时间:2023-11-30 18:09:35 24 4
gpt4 key购买 nike

如何从 C 编程语言的文本文件中读入一个包含空格、以分号分隔的字符串到数组中?

***from textfile***
"My Record; My Second Record; My Third"

。。。

    fopen ...
for(i = 0; i < 3; i++) {
fscanf_s(myFile, "%s", myRecords[i].title); /* this want read the records */
}
fclose...

最佳答案

最明显的可能性是使用 scanset 转换:

fscanf_s(myFile, "%[^;]", myRecords[i].title);

关于c - 从文本文件读入数组并使用 C 编程语言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1821789/

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