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

Pages: 1-

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 8:25

Anyone AT ALL? If you're experts it should take only a moment of your time.

Name: Anonymous 2009-02-25 8:27

changed to having

strcmp(whoru, whorua)== 0
strcmp(whoru, "namea")== 0

instead, same shit, right?
Still nothing working.

Name: Anonymous 2009-02-25 9:06

i think its because youre supergay

Name: Anonymous 2009-02-25 9:10

fgets puts the new line character.

Name: Anonymous 2009-02-25 9:37

Nice variable names.

Name: Anonymous 2009-02-25 9:57

amprisand? what >>5 said?

Name: Anonymous 2009-02-25 9:59

also, who formats there if's like that

Name: Anonymous 2009-02-25 10:10

>>8
Where if's?

Name: Anonymous 2009-02-25 10:48

>>9
what are you, blind?

 if (
       strcmp(whoru, whorua)== 0
        ) printf("A");

multiline if condition??? thjis is madness.

Name: Anonymous 2009-02-25 10:59

if (
       strcmp(whoru, whorua)== 0
       ) printf("A");

I lol'd

Name: Anonymous 2009-02-25 23:55

Your entire problem lies with fgets

Name: Anonymous 2009-02-25 23:59

>>12
Your entire problem lies with faggets

Name: Anonymous 2010-12-17 1:28

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2010-12-21 18:03

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