Hello. Your compiler is fairly clear in telling you what you are doing wrong.
Code:
FILE *fopen(const char *path, const char *mode);
The second parameter is a pointer to
const char. Your invocation is:
Code:
fopen(dumpFileName, 'a');
The second argument is
'a', which is a character literal, which in C++ has type
char. You could try this instead:
Code:
fopen(dumpFileName, "a");
"a" is a string literal, which has the appropriate type. Compiler warnings are important in general and in many cases should be seen as error indicators. Your compiler is letting you know that your call to
fprintf will most likely not do what you want it to do. I'd suggest breaking it into more (manageable) calls to
fprintf.
Having said that, why are you using C file I/O functions instead of C++ streams? I'm kind of guessing the answer, and it has something to do with the fact that you are writing object-based programs despite not being able to correct an error as simple as the one pointed out by your compiler.
Some further observations:
1. At best, the declaration of
dumpFileName is odd. You are not modifying it after it has been created and thus:
- There is no need to specify the number of elements. Your compiler will figure this out. The following would not only be enough but also superior at least from a memory-usage point of view: char dumpFileName[] = "...".
- Express the fact that you have no intention of modifying the contents of dumpFileName through code: const char dumpFileName[] = "..."
2. You are not checking the return value of
fopen (and I must assume that this is a general trend throughout your code). Most likely you should be doing it.