ok so here is part of the code I am working on, it's sort of a manipulation of the code from above:
Code:
if(sort_input == 'n') //NAME SORT
{
for(i = 0; i < (M-1); i++)
{
for(j = (i+1); j < M; j++)
{
if(strcmp(entry[i].name, entry[j].name) > 0)
{
for(i=0; i< SIZE+1; i++)
{
name_temp[i] = 0;
}
strcpy(name_temp, entry[i].name);
printf("%s", name_temp);
// entry[i].name[0] = '\0';
// strcpy(entry[i].name, entry[j].name);
// entry[j].name[0] = '\0';
// strcpy(entry[j].name, name_temp);
}
}
}
}
The problem is when it goes through this part, I'm getting an output for the printf of name_temp (this is for debugging purposes...) to be ??????? . For some reason it seems like the strcpy isn't working.
For the entries that are being compared, I put in David, then I put in Alvin, so that David would be in index 0, and Alvin would be index 1. So if I understand it correctly, David > Alvin thus it should process through the statement within the IF statements?
Can someone help?