bug

Jun 25, 2013 at 2:02am
cant figure out whats wrong with it it just wont compile

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# include <iostream>
# include <string.h>

using namespace std;

int main()
{
	string spare;
	cout << "menu" << endl;
	cout << "start" << endl;
	cout << "exit" << endl;
	cin >> spare;
	if (spare == "exit") return 0;

}
Jun 25, 2013 at 2:07am
Instead of <string.h> (C char array handling functions) try including <string> (C++ string class)
Jun 25, 2013 at 2:12am
thanks its always worked with .h though strange that that fixed it
Jun 25, 2013 at 2:19am
thanks its always worked with .h though strange that that fixed it


What was probably happening was that <iostream> was #including <string> without you realizing it. Which is why it may have worked before but not now.
Topic archived. No new replies allowed.