How do I fix this

when testing for run time errors i came upon the fact that the input was weird i think it has something to do with getline
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string priorities[10]={"Fill Out","Fill Out","Fill Out","Fill Out","Fill Out","Fill Out","Fill Out","Fill Out","Fill Out","Fill Out"};
	int menu=0;
	while (menu!='x')
	{
		system("cls");
	cout << "                          To fill out write the number.                         " << endl;
	cout << "Priorities" << endl;
	cout << "================================================================================" << endl;
	cout << "1 ) " << priorities[0] << endl;
	cout << "2 ) " << priorities[1] << endl;
	cout << "3 ) " << priorities[2] << endl;
	cout << "4 ) " << priorities[3] << endl;
	cout << "5 ) " << priorities[4] << endl;
	cout << "6 ) " << priorities[5] << endl;
	cout << "7 ) " << priorities[6] << endl;
	cout << "8 ) " << priorities[7] << endl;
	cout << "9 ) " << priorities[8] << endl;
	cout << "10) " << priorities[9] << endl;
	getline(cin,priorities[0]);
	getline(cin,priorities[1]);
	getline(cin,priorities[2]);
	getline(cin,priorities[3]);
	getline(cin,priorities[4]);
	getline(cin,priorities[5]);
	getline(cin,priorities[6]);
	getline(cin,priorities[7]);
	getline(cin,priorities[8]);
	getline(cin,priorities[9]);
	cin >> menu;
	switch (menu)
	{
	case 1:
		cin >> priorities[0];
		cin.ignore();
		cin.clear();
		break;
	case 2:
		cin >> priorities[1];
		cin.ignore();
		cin.clear();
		break;
	case 3:
		cin >> priorities[2];
		cin.ignore();
		cin.clear();
		break;
	case 4:
		cin >> priorities[3];
		cin.ignore();
		cin.clear();
		break;
	case 5:
		cin >> priorities[4];
		cin.ignore();
		cin.clear();
		break;
	case 6:
		cin >> priorities[5];
		cin.ignore();
		cin.clear();
		break;
	case 7:
		cin >> priorities[6];
		cin.ignore();
		cin.clear();
		break;
	case 8:
		cin >> priorities[7];
		cin.ignore();
		cin.clear();
		break;
	case 9:
		cin >> priorities[8];
		cin.ignore();
		cin.clear();
		break;
	case 10:
		cin >> priorities[9];
		cin.ignore();
		cin.clear();
		break;
	}
	}
	return 2182;
}
Last edited on
what do you even want it to do? It worked fine for me
for me it writes the list out then you have to press enter 10 times before you can write a number let me try again tho i tried again it wrote list then i wrote input with a space and then nothing happened???
Last edited on
when i took all the getlines out it worked how i wanted it to except it doesnt accept more than one word??????????????????????????????
Last edited on
This maybe what you are looking for.
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

#include <iostream>
#include <string>
using namespace std;
int main()
{
	string priorities[10];
	fill(priorities,priorities+10,"Fill Out");
	int menu=0;
	while (menu!='x')
	{
		system("cls");
	cout << "                          To fill out write the number.                         " << endl;
	cout << "Priorities" << endl;
	cout << "================================================================================" << endl;
for(int i = 0 ; i < 10;i++)
{
	cout << (i+1)<<" ) " << priorities[i] << endl;
}
	cout<<"Enter  Corresponding Number To Chart Here:  :";
	cin >> menu;
	cin.ignore();
	

	switch (menu)
	{
	case 1:
		cout<<"Type in your string :";
		getline(cin,priorities[0]);
		break;
	case 2:
		cout<<"Type in your string :";
		getline(cin,priorities[1]);
		break;
	case 3:
		cout<<"Type in your string :";
		getline(cin,priorities[2]);
		break;
	case 4:
		cout<<"Type in your string :";
		getline(cin,priorities[3]);
		break;
	case 5:
		cout<<"Type in your string :";
		getline(cin,priorities[4]);
		break;
	case 6:
		cout<<"Type in your string :";
		getline(cin,priorities[5]);
		break;
	case 7:
		cout<<"Type in your string :";
		getline(cin,priorities[6]);
		break;
	case 8:
		cout<<"Type in your string :";
		getline(cin,priorities[7]);
		break;
	case 9:
		cout<<"Type in your string :";
		getline(cin,priorities[8]);
		break;
	case 10:
		cout<<"Type in your string :";
		getline(cin,priorities[9]);
		break;
	default : 
		cout<<"Not Valid Choice"<<endl;
		break;
	}
	}
	return 0;
}
Last edited on
Topic archived. No new replies allowed.