Use "int main(void)" not "void main()",
#1: Do you mean when the program is executed from within
the VC IDE? It works fine here.
#2: You can use "getch();" from the <conio.h> header.
Code:
#include <string>
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
int main(void) // Use int main! Not void, Reason is the OS needs a return result from the program
{
ifstream in("FillString.cpp");
string s, line;
while(getline(in, line))
s += line + "\n";
cout << s;
getch(); // A cleaner method to hold to program until a key is pressed
return 0;
}