If you've got precompiled headers enabled for the compilation, stdafx.h must come first. The compiler ignores everything that come before it.
Also, why the duplicated file names? And the mixing of STL versions?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
#include "stdafx.h" // must come first!
#include <windows.h>
#include <string>
#include <fstream>
#include <iostream> // "iostream.h" is the older STL (with no std namespace)
//#include <string> duplicate
#include <cstdlib> // better than including <stdlib.h> directly
// and all standard header should be in <>
//#include "stdafx.h" moved
int main(int argc, char* argv[]) {
char buffer[1024];
std::cin.getline(buffer, 1024);
std::cout << "buffer: " << buffer << std::endl;
//printf("Hello World!\n");
return 0;
}
|
vc6 is prob not a disaster if you're not into heavy templating. But we used StlPort in place of the STL provided by Microsoft (if was not up to spec in those days).
But, unless you need MFC, I would do as Mochops suggested, and switch to a nice, shiny, new modern version of Visual Studio or Code::Blocks or ...
Andy
PS @codekiddy - the _TCHAR is just a typedef of wchar_t -- when _UNICODE is #defined --
or char otherwise. Similarly, _tmain is a macro that evaluates to either wmain or main. See <tchar.h> for too much detail.