warning when printing to file

Hi guys.

In my code, I need to print to a file from time to time. I use the following lines:

1
2
3
4
5
FILE * outFile;
outFile = fopen(fileName,"w");
tempLine << "%e"<< tempPos[0] << "\t";
tempLine >>line;
fprintf(outFile,  line);


however, I get a warning saying:

format not a string literal and no format arguments


I cannot understand the logic behind the format part in the documentation of fprintf in this site.

I would appreciate any help.

Yotam
If I understand your problem correctly, try this:

fprintf(outFile, "%s", line);

Format prints text on display and arguments, when they are specified. For example: to print two int values and char value you should write something in this shape:

1
2
3
4
int Number=2;
int AnotherNumber=56;
char Symbol='R';
printf("Number is %d, another number is %d and symbol is %c", Number, AnotherNumber, Symbol);


I hope this'll help.
Thanks,

I'll try this out tomorrow). I think I got what you mean.

thanks.
Topic archived. No new replies allowed.