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" <> a écrit dans le message de
news:00f88dc4-a3dd-4f4d-915a-...
> 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
|