This question already has an answer here:
- How do I properly compare strings? 6 answers
In the code below, I'm expecting the following to output "Application number is 100" Why is it printing "Application number is not 100" if when I'm printing and reading that it is indeed "100"?
#include <stdio.h>
int main()
{
char application_number[] = "100";
printf("Application number: %s\n", application_number);
if (application_number != "100")
{
printf("Application number is not 100");
}
else
{
printf("Application number is 100");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire