I'm coded function which splits 2 char arrays and integer into one string and returns pointer to new char array, but when compiling I'm getting this warning:
warning: assignment makes pointer from integer without a cast
mapfile = world_to_char( "maps/", map, ".bin" );
^
Here is my code, first two are lines from file where gcc is giving warning to me:
char *mapfile;
mapfile = world_to_char( "maps/", map, ".bin" );
and function (I know that it works only with numbers from [0;99], but it's enough for me):
char *world_to_char( char dir[], int number, char ext[] ) {
char id[ 3 ] = { 0, 0, 0 };
if( number > 9 ) {
id[ 1 ] = ( number % 10 ) + '0';
number /= 10;
}
id[ 0 ] = number + '0';
char *map;
map = malloc( MAX_MAP_FILENAME * sizeof( char ) );
strcpy( map, dir );
strcat( map, id );
strcat( map, ext );
return map;
}
Why I'm getting this warning? I'm returning pointer not integer.
gcc -O3 -g -std=c11 -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Werror. You can be more stringent if you like.