Hello...
I don't know why, but valgrind keeps giving me this error:
Code:
==2187== Conditional jump or move depends on uninitialised value(s)
==2187== at 0x40A550B: vfprintf (vfprintf.c:1614)
==2187== by 0x40C370B: vsprintf (iovsprintf.c:43)
==2187== by 0x40AC1DA: sprintf (sprintf.c:34)
==2187== by 0x80492DA: OpenFiles (files.c:41)
==2187== by 0x80487F7: main (main.c:30)
==2187== Uninitialised value was created by a heap allocation
==2187== at 0x4024F20: malloc (vg_replace_malloc.c:236)
==2187== by 0x804925E: OpenFiles (files.c:34)
==2187== by 0x80487F7: main (main.c:30)
Function OpenFiles:
Code:
Files_str *OpenFiles(char *arg){ /* this function changes the file extension */
char *fpInName, *fpOutName;
fpInName = arg; /* arg is something like this: "blablablablabla.txt" */
fpOutName = (char *) malloc(strlen(fpInName) + 1); /* LINE 34 */
if(fpOutName == ((char *) NULL)){
fprintf(stderr, "ERROR!!! Failed memory allocation for fpOutName\n");
exit(1);
}
strncpy(fpOutName, fpInName, strlen(fpInName) - 4);
sprintf(fpOutName, "%s.exe", fpOutName); /* LINE 41 */
/* now fpOutName is something like this: "blablablablabla.exe" */
/* and fpInName is something like this: "blablablablabla.txt" */
.
.
.
.
I guess I'm doing something wrong... anyway, the program runs fine...