C了解的字符串,而不是文件 [英] C read in string instead file
本文介绍了C了解的字符串,而不是文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这种
INT主(INT ARGC,CHAR *的argv [])
{
FILE *文件=的fopen(文字,RB);
焦线[128];
而(与fgets(线,的sizeof(线),文件))
{
的printf(%S,行);
}
返回0;
}
我想从文件中删除负载。
这是该计划的一部分。
我想在与fgets离开
我试试这个
字符的文件[] =NAME = XXXX \\ nsurname = XXX \\ n ADRESS = XXX;
解决方案
如果我理解你的问题,你是支持它的系统上,的 fmemopen()
可以做你想做的。
I have this
int main(int argc, char* argv[])
{
FILE *file = fopen("text", "rb");
char line[128];
while(fgets(line, sizeof(line), file))
{
printf("%s", line);
}
return 0;
}
I would like to remove the load from the file. This is part of the program. I want to leave while fgets I try this
char file[] = "name = xxxx\nsurname = xxx\n adress = xxx";
解决方案
If I understand your question, and you're on a system that supports it, fmemopen()
might do what you want.
这篇关于C了解的字符串,而不是文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文