This is one of my attempts
Reads the file in to memory and then write it to file, if it would work...
works fine if I change webURL to a file on my computer
Code:
#include <stdio.h>
#include <stdlib.h>
int main () {
FILE * pFile;
long lSize;
char * buffer;
size_t result;
pFile = fopen ("http://www.radar4u.com/REAB_groto/downld02.txt" , "rb" );
if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
// obtain file size:
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file:
buffer = (char*) malloc (sizeof(char)*lSize);
if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
// copy the file into the buffer:
result = fread (buffer,1,lSize,pFile);
if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
/* the whole file is now loaded in the memory buffer. */
// Print on screen or to file...
// printf(": %s", buffer);
FILE * wFile;
wFile = fopen ("skriv.txt","w");
fputs (buffer,wFile);
// terminate
fclose (wFile);
fclose (pFile);
free (buffer);
system("PAUSE");
return 0;
}