So, I've got a program that parses expressions in a line of text such as
11110000 & 11001100 ;
and evaluates the binary results. My code is parsing correctly and evaluating correctly, but for two of my test inputs (including the one above) my printf is also printing these weird symbols after each run.
eos$ ./interpreter < program02.txt
11000000 +
eos$ ./interpreter < program02.txt
11000000 2ñ
eos$ ./interpreter < program02.txt
11000000 "]
eos$ ./interpreter < program02.txt
11000000 ÒØ
eos$ ./interpreter < program02.txt
11000000 Ê
eos$ ./interpreter < program02.txt
11000000 òJ
The string is malloc'd like this
char *str = ( char * ) malloc ( ( getLength( src ) + 1 ) * sizeof( char ) );
And here is how the string is printed
char *str = binaryToString( val );
printf( "%s\n", str );
Any help would be awesome! Thanks!