Creating text files with %d id in c -
I was wondering how to create a text file like this:
For example If I have:
file * f; Int id = 1; F = fopen ("file \% d.txt", "a");
At the end of the file, I would like to add the ID number. I tried several things but nothing worked.
Whatever you actually try to do, have failed to show it.
The typical solution is to use sprintf () :
char fnbuf [1024]; Int a = 1; Sprintf (FNBF, "file% d.txt", A); F = FOPAN (FNBF, "A");
Note that this is very safe, but with a more complexity in a real program it is a good idea to use, and of course to check return values.
Comments
Post a Comment