Hi all,
I need to read bam file in my project. I met a problem. According to sam file format, the first information of bam file is: char[4]
which is BAM\1
. But my output is ?
. Can you tell my what is wrong of my codes? Thank you!
My codes (C++ or C) is here:
ifstream is(argv[1],ifstream::binary);
char magic[4];
is.read((char *)magic,sizeof(char)*4);
cout<<magic<<endl;
or
FILE *stream;
stream=fopen(argv[1],"r");
char magic[4];
fread(magic,sizeof(char),4,stream);
cout<<magic<<endl;
It works! Thank you so much!