Hallo
I am new at C so please forgive me for the simple question. I am trying to understand how to append some code to a text file. I have run a simple program like the one below. Basically it opens a text file and then it appends the string aaaaaaaaaa
Code:
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
char s[10] = {"\naaaaaaaaaa"};
int main(void)
{
FILE *file = fopen("test.txt", "a");
fputs("\nHallo World",file);
fputs(s,file);
fclose(file);
system("PAUSE");
return 0;
}
Now that I know how to append the above string, I now would like to extend the experiment to append the following snipped of code in my test.txt file:
Code:
<Placemark>
<name>12:01</name>
<Snippet maxLines="0"></Snippet>
<description>&nbsp;</description>
<styleUrl>#gv_waypoint</styleUrl>
<Point>
<coordinates>30,-29,0</coordinates>
</Point>
</Placemark>
How do I go about doing this? The problem I am experiencing is that all the / and " characters in the above snippet of code seems to get the C compiler confused. I have limited knowledge on this subject and I would appreciate some guidence.
One thought I had was to create a string like the one below but as I mentioned, the number 0 in the code is surrpunded by " " and this confuses the compiler:
Code:
char s[250] = {"<Placemark>
<name>12:01</name>
<Snippet maxLines="0"></Snippet>
<description>&nbsp;</description>
<styleUrl>#gv_waypoint</styleUrl>
<Point>
<coordinates>30,-29,0</coordinates>
</Point>
</Placemark>"} ;