-
Printing into a file
Hi I have a particularly creepy problem :( eating my head from quitea few days.
I have a large array of size say 3000, at the end of the program i have certain computations done and stored as elements of this array, now i want to print the elements from this array into a file.
I am using fprintf , and using a while loop to print until the length of the string is zero.
the problem is that i get empty lines added automatically in between and also that sometimes the data is broken into 2 lines when displayed. please help!
Code:
while(strlen(StringCup[iz])!=0)
{
fprintf(f1,"%s\n",StringCup[iz]);
printf("%s\n",StringCup[iz]);
iz++;
}
-
Post a compilable example. Chances are, though, some of the strings have the character '\n' embedded in them.