hi take a look at this source code (it doesn't have bugs):
Code:
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
FILE *fp;
int c;
if ( (fp = fopen("TEXT.TXT", "rb")) == NULL)
{
fprintf(stderr, "Error opening file.");
exit(1);
}
while ((c = fgetc(fp)) != EOF)
{
printf("%c ", c);
}
fclose(fp);
return 0;
}
(in TEXT.TXT there's one line of the alphabet's characters(abcd...))
it runs fine but fgetc gives me the actual letters in the text file.
what i wanted it to print was the binary values byte by byte (like 01011001)
how can i achieve that?