Bubble Sort help please

I have been working on this assignment, and it says i have to sort a 2d record array based on the type of record so if its an id its an int and if a name its a string, my problem is when i begin using my bubble sort, it seems to not save the previous Array so it does not sort or anything. The Search(RecordArray,temp,n,i) is a function that finds the comma and gets all values before it to compare later on.
This is just my bubble sort. Thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
for (int i=1;i<length;i++)
				{	
					char temp1[100]="";
					char temp2[100]="";
					Search(RecordArray,temp1,n,i);
					Search(RecordArray,temp2,n,i+1);
					int x,z;
					x=atoi(temp1);
					z=atoi(temp2);
					if(x>z)
					{
						char *y=&RecordArray[i][256];
						RecordArray[i][256]=RecordArray[i+1][256];
						RecordArray[i+1][256]=*y;	
					}	
					
				}
Last edited on
I do not understand what you save in RecordArray.
My advice use struct.
like struct Record
{
int id;
string name;
};

in main you can write
Record a1[100]; // array of 100 elements of struct Record
Topic archived. No new replies allowed.