cicikamarena
New Coder
Does anyone know how I could maintain relations between the char and int in structs while merge sorting the ints in the struct? So if I had nameandnumber[1].buffer assigned a value that used to be at nameandnumber[7].buffer, nameandnumber[7].phrase would get moved to nameandnumber[1].phrase?
My struct
and then I put
later in main
I'm parsing a series of numbers that correspond with letters in a .txt file that sort of looks like this:
4 apple
2 pear
14 spaghetti
18 tea
1 coffee
so the numbers get put into buffer and the letters + spaces go into the phrase.
I'm merge sorting the numbers in buffer but how do I do that so 1 is still next to coffee rather than apple?
My struct
Code:
typedef struct
{
int buffer;
char phrase[30];
}
nameandnum;
and then I put
Code:
nameandnum *nameandnumber
I'm parsing a series of numbers that correspond with letters in a .txt file that sort of looks like this:
4 apple
2 pear
14 spaghetti
18 tea
1 coffee
so the numbers get put into buffer and the letters + spaces go into the phrase.
I'm merge sorting the numbers in buffer but how do I do that so 1 is still next to coffee rather than apple?