Note that there are some explanatory texts on larger screens.

plurals
  1. POERROR: Run-Time Check Failure #2 - Stack around the variable 'file' was corrupted
    text
    copied!<pre><code>#include &lt;string&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;windows.h&gt; #include &lt;wininet.h&gt; #include &lt;winsock.h&gt; #include &lt;stdio.h&gt; #include &lt;stdarg.h&gt; #pragma comment(lib, "wininet.lib") using namespace std; const int file_l = 100; int getpage() { HINTERNET hOpen, hURL; LPCWSTR NameProgram = L"Webreader"; //LPCWSTR == Long Pointer to Const Wide String LPCWSTR Website; char file[file_l]; unsigned long read; //Always need to establish the internet connection with this funcion. if ( !(hOpen = InternetOpen(NameProgram, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ))) { cerr &lt;&lt; "Error in opening internet" &lt;&lt; endl; return 0; } Website = L"http://www.sec.gov/Archives/edgar/data/1535079/000100201413000137/R2.htm"; hURL = InternetOpenUrl( hOpen, Website, NULL, 0, 0, 0 ); //Need to open the URL ofstream fout("Summer Research testing.txt"); InternetReadFile(hURL, file, file_l, &amp;read); while (read == file_l) { InternetReadFile(hURL, file, file_l, &amp;read); file[read] = '\0'; cout &lt;&lt; file; fout &lt;&lt; file; } fout.close(); cout &lt;&lt; endl; InternetCloseHandle(hURL); return 0; } int main() { getpage(); } </code></pre> <p>above is my code. I'm a beginner. Programming C++, using Visual Studio 2010<br><br> I have keep having the error: "<em>Run-Time Check Failure #2 - Stack around the variable 'file' was corrupted.</em>" <br> what I thought was that I shouldn't make the "*char file[file_l];*" the same length as others, so I changed it to "*char file[file_l+1];<em>" Apparently, problem solved, no more error. Could you please let me know whether this is the right way to fix this error? <br> <br> Also, the program didn't print all the HTML code of the webpage in to the file "</em>"Summer Research testing.txt"*"as I wanted. it didn't print from the line 1 and always stopped at line 209. I have changed things around, but very little progress. please help.<br> <br> Any help is greatly appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload