Junk

Deleted post.
Last edited on
It is not wrong per say. The only concern I see is cin >> gets only one word until you hit space or enter. So, mystring == "How are you?" is ignored. To overcome this problem, you need to use getline().

Last edited on
"cin.getline ()" right or is it different?
Also when I typed how are you the program closed even though that should be Bye being typed.
The call getline doesn't work when used "getline (mystring);"
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
33
34
35
36
#include <iostream>
#include <string>
using namespace std;
string mystring;
double i;

int main()
{ 
	i = 5;
	getline(cin, mystring);
	if (mystring == "Bye.") 
	{ 
		system("PAUSE");
		return 0;
	}
	if (mystring == "How are you?")
	{
		cout << " I'm a program, I don't have feelings."; 
	}
	i = 5;
	getline(cin, mystring);
	if (mystring == "Bye.") 
	{ 
		system("PAUSE");
		return 0;
	}

	if (mystring == "How are you?")
	{
	  cout << " I'm a program, I don't have feelings."; 
	  system("PAUSE");
	
	}

return 0;
}
Last edited on
Topic archived. No new replies allowed.