Here is my code: What it has to do is convert the webpage source into a .txt file, but unfortunately it is causing exceptions. In case anyone asks, I am using Visual C++ 2010 Express.
Why is it not working?
The code:
and here is the error:
1>------ Build started: Project: project1, Configuration: Debug Win32 ------
1> main.cpp
1>c:\documents and settings\alex\m y documents\visua l studio 2010\projects\p roject1\project 1\main.cpp(19): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_ WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include \stdio.h(234) : see declaration of 'fopen'
1>c:\documents and settings\alex\m y documents\visua l studio 2010\projects\p roject1\project 1\main.cpp(27): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_ WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include \stdio.h(234) : see declaration of 'fopen'
1>C:\Program Files\MSBuild\M icrosoft.Cpp\v4 .0\Microsoft.Cp pBuild.targets( 990,5): warning MSB8012: TargetPath(C:\D ocuments and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\project 1\project1.exe) does not match the Linker's OutputFile property value (C:\Documents and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\Debug\p roject1.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFi le).
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_cleanup referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_perform referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_setopt referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_init referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>MSVCRTD.lib(c rtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStar tup
1>C:\Documents and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\Debug\p roject1.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Why is it not working?
The code:
Code:
#include "curl.h"
#include "easy.h"
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
CURL *curl;
FILE *fp;
CURLcode res;
long lSize;
char *translated;
void Func() {
curl = curl_easy_init();
if(curl) {
fp = fopen("C:\\trans.txt","wb");
curl_easy_setopt(curl, CURLOPT_URL, "http://paaaagggeeee.com/123.html");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
fp = fopen("C:\\Output.txt","rb");
fseek (fp , 0 , SEEK_END);
lSize = ftell (fp);
rewind (fp);
fread (translated,1,lSize,fp);
translated[lSize] = 0;
fclose(fp);
}
1>------ Build started: Project: project1, Configuration: Debug Win32 ------
1> main.cpp
1>c:\documents and settings\alex\m y documents\visua l studio 2010\projects\p roject1\project 1\main.cpp(19): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_ WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include \stdio.h(234) : see declaration of 'fopen'
1>c:\documents and settings\alex\m y documents\visua l studio 2010\projects\p roject1\project 1\main.cpp(27): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_ WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include \stdio.h(234) : see declaration of 'fopen'
1>C:\Program Files\MSBuild\M icrosoft.Cpp\v4 .0\Microsoft.Cp pBuild.targets( 990,5): warning MSB8012: TargetPath(C:\D ocuments and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\project 1\project1.exe) does not match the Linker's OutputFile property value (C:\Documents and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\Debug\p roject1.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFi le).
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_cleanup referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_perform referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_setopt referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_eas y_init referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>MSVCRTD.lib(c rtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStar tup
1>C:\Documents and Settings\alex\m y documents\visua l studio 2010\Projects\p roject1\Debug\p roject1.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========