I'm building a simple C program, which takes a user input parameter (URL) using scanf()
, as the code below reflects. I'm now looking for the best "standard" way to read/write the remote file to a local file... which I will then preform a grep (search) operation on the new local source file.
//CODE
#include <stdio.h>
int main(void){
char url[255];
//USER INPUT URL
printf("ENTER URL: ");
scanf("%s", &url);
//GET FILE AT URL(REMOTE) AND COPY TO (LOCAL)
//RETURN
return 0;
}
You could use libcurl, or just shell out and use wget
or curl
, honestly.
char command[1024];
snprintf(command, 1024, "wget -c '%s'", url);
system(command); // add error handling
That will take considerably less effort.