如何在c中用空格或逗号分隔的文件中写两个字符串?

时间:2011-01-27 09:30:06

标签: c file file-io file-handling

我有两个字符串,我想以下列格式将这些字符串写入FILE:

string1 "space/comma" string2 "newline"
string3 "space/comma" string4 "newline"
..
..
..

1 个答案:

答案 0 :(得分:5)

FILE* fileptr = fopen("file.txt","wt");
fprintf(fileptr,"%s , %s \n",string1,string2);