crazyfuturamanoob
November 22nd, 2008, 07:31 PM
I use C.
This string:
data/test.bmp
Will look like this:
�?�<Ϸ�?����=�.e#
With this code:
int line_max = 80;
char line[line_max];
char string[line_max];
strcpy( string, line );
// remove the endline character from string
string[strlen(string)-1] = '\0';
printf("%s\n", string);
Am I using wrong data types? How is this possible?
Edit: Solved myself.
When creating a string variable, it will be filled with garbage.
And I forgot to read the line from file before doing that part of code, lol.
This string:
data/test.bmp
Will look like this:
�?�<Ϸ�?����=�.e#
With this code:
int line_max = 80;
char line[line_max];
char string[line_max];
strcpy( string, line );
// remove the endline character from string
string[strlen(string)-1] = '\0';
printf("%s\n", string);
Am I using wrong data types? How is this possible?
Edit: Solved myself.
When creating a string variable, it will be filled with garbage.
And I forgot to read the line from file before doing that part of code, lol.