Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C cmpstr question

Name: Anonymous 2009-02-25 8:09

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main ()
{
    char whorua[10] = "namea";
    char whorub[10] = "nameb";
    char whoru[10];
  
    printf( "whoru? namea or nameb? \n" );
    fgets( whoru, 10, stdin );
    if (
       strcmp(whoru, whorua)== 0
        ) printf("A");
    else if (
             strcmp(whoru, whorub )== 0
             ) printf("B");
    else
             printf("whoru? namea or nameb? \n");
            
    getchar();
    return 0;
}


it always prints A.
I'm still learning, but I don't know how to use cmpstr properly.

Name: Anonymous 2009-02-25 10:10

>>8
Where if's?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List