In the below code I'm creating two files one in text format and other in binary format. The icons of the files show the same. But the characteristics of both the files are exactly same including the size ,charset (==binary) and stream(octet). Why isn't there a text file? Because if i create a text file explicitly the charset is ASCII.
Compiler version - gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0.
Operating system - Tried on both Ubuntu 18.10 and 19.04.
No messages displayed by compiler.
Command used to examine the files
file --mime
.Output by the command for file
Text1.txt
:Text1.txt: application/octet-stream; charset=binary
Output by the command for file
Text1.txt
:Binary: application/octet-stream; charset=binary
Output by command
od -xa FILENAME
is same for both files and is :
0000000 0021
! 0000001
#include<stdio.h>
void main(){
FILE *fp;
FILE *fp2;
int a = 10111110;
fp2 = fopen("Text1.txt","w");
fputc('!',fp2);
fp = fopen("Binary","wb");
fputc('!',fp);
}
Expected output is One File with charset as ASCII and One with Binary, Actual output is both of them with charset as Binary