Converting String to Char

Pages: 12
try operator >> as mentioned earlier getline reads until the new line character '\n' and operator >> reads until the next white space ( space , tab , newline , ect.. )

so something like

1
2
3
4
5
while( inFile.good() )
{
    inFile >> char_array[i];
    ++i;
}
I tried that but it doesnt recognize the spaces.
Ok, I think I'm going crazy and over analyzing all this. I figured it out. I essentially imported the file into a INT array and typecasted it out. Thanks all for helping.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
void message()
{
	ifstream inFile;
	string messageIn[2000];
	char messageChar[2000];
	int messageInt[2000];
	
	

	
	
	inFile.open("message.dat", ios::in);

	if(inFile.fail())
		{
			cout << "File did not open!";
			Sleep(2000);
			exit(1);
		}

	else
	
		for (int i=0; i<2000;i++)
		{
			inFile >> messageInt[i];
			cout << (char)messageInt[i];
		}		
		
		inFile.close();		
	
}
Topic archived. No new replies allowed.
Pages: 12