How can i read in exe file with C?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdlib.h>
#include <stdio.h>
int main(){long ilk,son;
    char *a;
    int i;
FILE *dosya;
*a=fgetc(dosya);
dosya=fopen("C:\\name.exe","rb");
char b[sizeof(*a)];
b[sizeof(*a)]=fgetc(dosya);
itoa(i,b,2);
printf("%s",b);
system("PAUSE");
fclose(dosya);
return 0;}

How can i do this?Must i uncompress this exe file?
You won't get any useful data this way, unless this happens to be a text file that someone has changed the extention on. Are you trying to Reverse Engineer this executable?
Last edited on
No.I am trying take voice wave binary datas in a .wav file. .wav or .exe files are in windows os.

You should look into using a third party library then. I would suggest SFML for this because you can get started with it in a weekends worth of time.
Thks for ur exegesis.
char b[sizeof(*a)]; declares an array of 4 bytes (with 32bit pointers).
b[sizeof(*a)]=fgetc(dosya); is writing beyond the end of the array.
Topic archived. No new replies allowed.