int main()
{
    FILE *fp;
    unsigned long size;
    unsigned char *loc;
    fp=fopen("Hello.exe","rb");
    if(fp==NULL)
    {
        printf("\nCouldn't load file");
        getchar();
        return 0;
    }

    fseek(fp,0,SEEK_END);
    size = ftell(fp);

    fseek(fp,0,SEEK_SET);

    loc=(unsigned char*)malloc(sizeof(size));
    printf("\nSize of  file is : %d",size);
    if(loc==NULL){
    printf("\nError in allocating memory.");

    }
    printf("\nFread called");
    fread(loc,size,1,fp);
    printf("\nFread fails:");


    return 0;
}

I was trying to load a "Hello World" application into heap and this fread hangs me out.
Can anybody figure out why is this happening out!

anti-virus software

fread is fine. Look at a line 19. How much memory did you allocate?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.