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.
#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.