-7

this is my bad code I don't want to display the name if it is null but the condition doesn't work (the program is running well except the condition part) what I have to do???

case(4):
        printf("\n\n\n DISPLAY ALL INFORMATION \n\n");
        for(i=0;i<50;i++){
                 if(st[i].name=="null")
                 {
                    break;
                 }else{

                printf("\n\n\n");
                printf(" student name = %s",st[i].name);
                printf(" \t student id =%d",st[i].id);
                    printf("\n**************************************************************************************");
                 }

        }
        printf("\n\n\ndo you want to see the main menu???yes(1)no(2)");
        scanf("%d",&ans9); if(ans9==1){
            system("cls");
            goto loop1;}
        break;
H.S.
  • 11,654
  • 2
  • 15
  • 32

1 Answers1

0

How you initialized your name variable? As per coding standard we should initialize it with 'NULL' Character. Use st[i].name==NULL. It seems "null" is being treated as a string, in that case you should use strncmp(st[i].name, "null", 4)

Ravi
  • 140
  • 6