|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
when i try to read the first byte from an EXE file it's give different
results code: FILE *me,*u; char buf_me[1]; char buf_u[1]; me= fopen(argv[0],"rb"); u= fopen(argv[1],"rb+"); fread(buf_me,sizeof(char),1,me); fread(buf_u,sizeof(char),1,u); printf("%s\n",buf_me); printf("%s\n",buf_u); ---- when you run this code and put EXE file as an argument , the program will print M MM why it double the byte in the second time |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Put this instead:
printf("%c\n",buf_me); // %c printf("%c\n",buf_u); // %c You can assume your variables are one to the other into the memory. When you send a string to printf, it's gonna write it untill it finds the character '\0' which is not present here. "Medvedev" <3D.v.World@gmail.com> a écrit dans le message de news:00f88dc4-a3dd-4f4d-915a-28cc6b816730@a70g2000hsh.googlegroups.com... > when i try to read the first byte from an EXE file it's give different > results > code: > FILE *me,*u; > char buf_me[1]; > char buf_u[1]; > > me= fopen(argv[0],"rb"); > u= fopen(argv[1],"rb+"); > > fread(buf_me,sizeof(char),1,me); > fread(buf_u,sizeof(char),1,u); > > printf("%s\n",buf_me); > printf("%s\n",buf_u); > > ---- > when you run this code and put EXE file as an argument , the program > will print > M > MM > > why it double the byte in the second time |
|
![]() |
| Outils de la discussion | |
|
|