-
fprintf problem
Hi, I have a problem with fprintf(File *arg1, char * arg2) for I wanted to print an integer or a double variable onto a file. As far as I know, the fprintf command can only allow a string, or a character pointer in argument 2. Can somebody help me in telling me what to do or where to look for in allowing fprintf to accept integer/double variables or possibly ways to convert integer or a double into a char*?
-
The second argument to fprintf is a format string, so it works nearly identically to printf.
Therefore :
For doubles :
Code:
fprintf(file_pointer_name, "%f", double_value);
For intergers :
Code:
fprintf(file_pointer_name,"%d", integer_value);