Hello there.
I have been following these tutorials:
http://www.cplusplus.com/doc/tutorial/tut6-1.html
http://cplus.about.com/library/weekly/aa022402a.htm
and did a bit of googling, but can't seem to find how to input from a text file and echo exactly what's in it (I can get it to echo without spaces, but that doesn't really help..)
here's what I'm using:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#define welcomemsg "Welcome to my Message Keeper!"
string tx;
int main()
{
cout << welcomemsg << endl << "Enter the number of the message you wish to read then press enter." << endl;
ifstream msgList;
msgList.open("msglist.txt");
if (! msgList)
{
cout << "Error opening input file" << endl;
return -1;
}
while (msgList >> tx) {
cout << tx;
}
return 0;
}
---
(contents of msglist.txt is "Hello there!"
any help would be appreciated, I'm just starting!!