[英]C language - Read specific data from text file
I'm studying file I/O.我正在研究文件 I/O。 I have a trouble in reading specific data.
我在读取特定数据时遇到问题。
text file :文本文件 :
index (x,y)
1 2,3 1,5 8,2
2 4,4
3 0,1 9,4
4
The number of (x,y)
can be changed. (x,y)
可以改变。
I read only numbers with following code:我只阅读了以下代码的数字:
while (1){而 (1){
getNum = fscanf(fp, "%d", &num);
if (getNum == EOF)
break;
else if (getNum < 1)
fscanf(fp, "%*[^0-9]");
else
printf("%d\t", num);
}
How can I split index, x, y?如何拆分索引,x,y?
Follow these steps:按着这些次序:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.