View Single Post
Old 03-13-2003, 07:44 AM   #1 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Angry Omg, it's been a while: fstream help pls.

// Read an entire file into a single string
#include <string>
#include <iostream>
#include <fstream>
using namespace std;

void main() {
ifstream in("FillString.cpp");
string s, line;
while(getline(in, line))
s += line + "\n";
cout << s;
}

This program works. But when running in VC++ 6 IDE the console doesn't show the contents of the FillString.cpp file.
BUt when executed by the exe, it does, though I have to insert cin.get() at the end.

Q1:
Why doesn't the output show in the IDE?

Q2:
cin.get() is ugly.
What was the other method to hold the console, only waiting for a button to close? I totally forgot.

Thx in advance,
Val
Valmont is offline   Reply With Quote