2d array element shifts

i need to horizontally right and vertically up shift the elements of a 2d character array. i have come up with the code below for two separate functions, and it just doesn't want to finish correctly. i just want everything in the user given row to move to the right one space. same with the column going up one space. any hints or input to set me on the tracks again is very appreciated...

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
void cycleright(char matrix[][noCols], int n)
{
	char temp;	int row, c;
	cout << "Performing row cycle right...\n";
	cout << "Which row would you like to cycle right...?\n";
	cin >> row;
	for(int i=0; i<n; i++)
	{
		c = n-1;
		temp = matrix[row][c];
		if((c-1)>=0)
		{
			matrix[row][c] = matrix[row][c-1];
			c--;
		}
		matrix[row][c] = temp;
	}
	return;
}
void cycleup(char matrix[][noCols], int n)
{
	char temp;	int col, r;
	cout << "Performing column cycle up...\n";
	cout << "Which row would you like to cycle up...?\n";
	cin >> col;
	for(int i=0; i<n; i++)
	{
		r = n-1;
		temp = matrix[r][col];
		if((r-1)>=0)
		{
			matrix[r][col] = matrix[r-1][col];
			r--;
		}
		matrix[r][col] = temp;
	}
	return;
}
Topic archived. No new replies allowed.