C语言 读取文件中特定数据

//读取文件数据

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h> struct jiang{
char one[];
char two[];
}str[]; void main(){
//定义数据
int arr[] = { };
//定义文件路径
char path[] = "E:\\Look\\b.txt";
//定义文件指针
FILE *pf=NULL;
//打开读写文件
pf = fopen(path, "r");
//判断是否打开文件
if (pf==NULL)
{
printf("文件打开失败!");
return;
}
int index = ;
//读文件
while (!feof(pf)){
//\t就是文本中的空格,不管有多少个空格 都是一个\t
fscanf(pf, "%s\t%s\n", str[index].one, str[index].two);
index++;
}
//关闭文件指针
if (pf!=NULL)
{
fclose(pf);
}
for (int i = ; i < ; i++)
{
printf("%s,%s\n", str[i].one, str[i].two);
}
system("pause");
}

C语言 读取文件中特定数据

上一篇:linux配置本地tomcat应用80端口转发


下一篇:[Android]通过setImageURI设置网络上面的图片