Writing String to File in C

vozzz

New Member
I am in the process of writing an HTTP client that basically goes to a webpage and downloads the content to a separate file, which the user defines. I am having trouble not with the act of writing to a file itself, but I'm getting a strange problem. I'll show a couple of the code snippets below, but basically when there is a\[code\] fprintf(stdout, "%s", htmlcontent);\[/code\]where htmlcontent is defined as\[code\] char *htmlcontent;\[/code\]it prints out the entire HTML page information to the standard output. I can also redirect this output to a file in the command line by saying >myfile.txt (Yes, I want to compare the text files instead of html files).But when I do something like this:\[code\] fprintf(savedfile, "%s", htmlcontent);\[/code\]where savedfile is defined as\[code\] FILE *savedfile;\[/code\]and it is opened like this:\[code\] savedfile = fopen(filename, "w");\[/code\]where filename is defined as\[code\] char *filename;\[/code\]and is set equal to the command line argument that corresponds to it. When I do the second type of fprintf to print it out to my file instead of the standard output, I do not get the same thing and i can't figure out why. Can anybody help me understand why there would be any difference? If you want me to post the two different programs so you can see them in their entirety just let me know and I'll do that.
 
Top