I programmes a Tetris game, and as a part of it, I made ranking system. The ranking is saved in a text file, and it's read and saved in a linked list at the beginning of the program. Each node has name(string), score(integer), linke for next node(node pointer). The function I'm trying to add is finding a certain player's rank when the player's name is given. But when I tried with my code, it couldn't find the player.
I've tried using the code below, but it didn't work.
printw("Input the name: ");
echo();
getstr(name);
noecho();
printw(" name | score \n");
printw("----------------------------\n");
for(int i=0;i<rlen;i++){
if(cur->name==name){
flag=1;
printw("%-16s| %d\n", cur->name, cur->score);
}
cur=cur->next;
}
if(flag==0) printw("\nsearch failure: no name in the list\n");
break;
For example, if there was a player whose name is aaaa and he scored 1000, if I input aaaa, It should print aaaa | 1000 But instead it prints the search failure message.