Thread: How To ????

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    2

    How To ????

    well I had it figured out at one point in time but know I just cant do it ......

    I want to do something like this ...


    char hello[5];

    scanf ("%s",hello);

    while ( hello=='hi')

    {

    do this


    }

    else

    do this


    ......


    so basicly I want the user to input a string and if that string is = to the string I specify (hi) do a loop else continue with the program ....

    I know its probly the easiest thing to do

    but I totally forget how the code is supose to be

    hope you all can help


    tnx

    velosity

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    if ( strcmp( hello, "hi" ) == 0 )

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You both should go read the announcements and learn how to use code tags.

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Nov 2004
    Posts
    2
    OK nevermind I just remembered


    tnx anyways


    here it is for all to see


    if( ( strcmp(hello, "hi") == 0) || ( hello(again, "Hi") == 0) )

    strcmp - compares the 2 strings and ones it sees that they are identical it returns the number 0 so changes the code to 0



    tnx again


    velosity

  5. #5
    Registered User
    Join Date
    Jun 2004
    Posts
    722
    Quote Originally Posted by velosity1
    if( ( strcmp(hello, "hi") == 0) || ( hello(again, "Hi") == 0) )
    "hello" is the name of a variable, and you're using it as a function in the 2nd parameter. Did you try to compile your code? That wouldn't compile.

Popular pages Recent additions subscribe to a feed