long len;
char* buf = NULL;
FILE* fp = NULL;
fp = fopen( "File.txt", "rb" );
if (fseek( fp, 0, SEEK_END ) != 0)
{
fclose( fp );
}
len = ftell( fp );
rewind( fp );
buf = (char*)malloc( len );
if (!fread(buf,len,1,fp)) return;
fclose( fp );
printf(buf);
My File.txt:
Testing
Test
But i'm getting a problem..
It returns all strings of my text, but at end the text, appear symbols like:
Testing
Test.¶♠ // Like it
or
Testing
Test.log// Like it also
I should use '\0' to clean empty bytes but i haven't any idea of how can i use here..
Thanks!