Logical operations not working

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
int main()
{
	char rORc, choice;
	int sizerc;
	
	values(x, s);
	displaytable(x, s);
	do
	{
		prompt(rORc, sizerc);
		if(rORc == '_')
		{
			sortbyrow(sizerc, p, x);
			displaytable(x, s);
		}
		cout << "Exit - y or n ";
		cin >> choice;
	}
	while(choice != 'y');
	return 0;
}
void prompt(char rc, int size)
{
	cout << "Enter row or col using _ or | followed by" 
		 << "\nthe row or column you wish to sort "
		 << "\n(row [0-11), col [0-5]): "; 
	cin >> rc >> size;
}
void sortbyrow(int size, const int proj, int xr[][p])
{
	int temp;
	for (int j = 0; j < proj; j++)
	{
		if(xr[size][j] > xr[size][j+1])
		{
			temp = xr[size][j];
			xr[size][j] = xr[size][j+1];
			xr[size][j+1] = temp;
		}
	}
}


Names:          P1      P2      P3      P4      P5      P6      AVER.

EVIKE           41      85      72      38      80      69      64.17
KKASV           65      68      96      22      49      67      71.86
YCXFX           51      61      63      87      66      24      70.64
FADPO           80      83      71      60      64      52      80.11
OEJUV           90      60      49      31      23      99      72.02
POEYL           94      11      25      24      51      15      48.67
VRVIP           13      39      67      97      19      76      59.94
QNQRQ           12      33      99      18      92      35      58.16
OOVAO           74      0       95      71      39      33      61.69
NCBXC           39      32      37      45      57      71      57.12
ATXDK           95      5       71      24      86      8       57.69
IXJSW           51      54      74      24      75      70      67.61
AVER.           58.75   49.15   72.35   51.11   62.68   56.81
Enter row or col using _ or | followed by
the row or column you wish to sort
(row [0-11), col [0-5]): _ 0
Exit - y or n n
Enter row or col using _ or | followed by
the row or column you wish to sort
(row [0-11), col [0-5]): _ 1
Exit - y or n


when I input the character which is the underscore, and the row # it should display the table and sort that specific row. Why is the if statement skipped? This is not the complete program but has everything needed.
You never change your rORc (or sizerc) variables. You are passing variables by value. That means an independed copy is crated for use in functions and changing it will not change originls. You may use return value or pass by reference to achieve what you want.
http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/
Okay I understand. Thanks a lot MiiNiPaa, I really appreciate the help. Still learning you know.
Topic archived. No new replies allowed.