I am reading a file that has a column of words, but each time the column is read, the first letters are the only things that are outputed.

Does anyone have any simple solutions to this? I don't want to have each letter be a separate variable.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;


int main()
{
	
	char EVENT_NAME;

	ifstream in("C:\\Dokumente und Einstellungen\\Yaser\\Eigene Dateien\\Internship\\C++_Code\\Data_3.txt");
	ofstream out("C:\\Dokumente und Einstellungen\\Yaser\\Eigene Dateien\\Internship\\C++_Code\\Output.txt");
	
	string line;

	while( in >> EVENT_NAME)
	{
	
	cout << EVENT_NAME << "\t"  << endl;
	
	}
	
return 0;
}

>>char EVENT_NAME;

That only declares a single character. you need an array, such as char EVENT_NAME[255]; or better yet string EVENT_NAME;

>>char EVENT_NAME;

That only declares a single character. you need an array, such as char EVENT_NAME[255]; or better yet string EVENT_NAME;

Please remember that if you use an array with operator>>, you also need to lock the upper limit so that cin does not overflow the array:

char EVENT_NAME[255];

// setw() is declared in the <iomanip> header
// the size for setw includes a null character for the array
while (in >> setw(255) >> EVENT_NAME)
{
    cout << EVENT_NAME << "\t"  << endl;
}

The string class is better because it grows dynamically. You do not need to worry about array overflow or how to deal with extra long strings.

Comments
Nice one here :)
Thanks for the correction :)
This question has already been answered. Start a new discussion instead.