用c++如何读取一个txt文档里的坐标点信息.如x=12.25,y=123.35等坐标信息.非常感谢哪位大侠能帮我实现一下
1个回答
展开全部
#include <stdio.h>
main()
{
FILE *fp;
fp=fopen("File_name.txt","r");
if(NULL==fp)
{
printf("Open the file Failed!\n");
}
else
{
printf("Open the file Succeed!\n");
}
char ch;
// ch = fgetc(fp);
while(ch!=EOF)
{
if ( 'x'==(ch=fgetc(fp))||'y'==(ch=fgetc(fp)))
{
while ((ch!='\n')&&(ch!='\0')&&(ch!=EOF))
{
putchar(ch);
ch = fgetc(fp);
}
ch = fgetc(fp);
}
}
fclose(fp);
return 0;
}
main()
{
FILE *fp;
fp=fopen("File_name.txt","r");
if(NULL==fp)
{
printf("Open the file Failed!\n");
}
else
{
printf("Open the file Succeed!\n");
}
char ch;
// ch = fgetc(fp);
while(ch!=EOF)
{
if ( 'x'==(ch=fgetc(fp))||'y'==(ch=fgetc(fp)))
{
while ((ch!='\n')&&(ch!='\0')&&(ch!=EOF))
{
putchar(ch);
ch = fgetc(fp);
}
ch = fgetc(fp);
}
}
fclose(fp);
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询