Reading and Writing to a file
I have already asked this question before but I didn't really get anywhere. But now I have a new way of explaining what I want to do.
The code below reads a file off my computer and then prints the contents of a.name
Code:
#include <stdio.h>
struct data
{
char name [50];
}a;
int main()
{
FILE *f;
f=fopen("file","rb");
fread(&a, sizeof(struct data),1, f);
printf("NAME: %s\n", a.name);
fclose(f);
system("PAUSE");
return 0;
}
That works fine. But if I want to read a file off the internet I put this
Code:
#include <stdio.h>
struct data
{
char name [50];
}a;
int main()
{
FILE *f;
f=fopen("http://dg1234ukpics.tripod.com/cgi-bin/file.dat","rb");
fread(&a, sizeof(struct data),1, f);
printf("NAME: %s\n", a.name);
fclose(f);
system("PAUSE");
return 0;
}
and it does not work!
I believe I have to use sockets but is it somthing called winsock I have to learn becuase I'm using windows?
Please help
Thanks