Thread: If then Else statement help

  1. #1
    Registered User
    Join Date
    Mar 2010
    Location
    Salem's Lot
    Posts
    19

    If then Else statement help

    if (condition) statement1 else statement2

    How do I say, if what the user typed in equals the string that I want it to equal then execute the function.

    Thanks,

    -Nos

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Use strcmp() to compare strings.

    Code:
     
    char a[] = "nosfearatu" ; 
    char b[] = "nesfearatu" ; 
    
    if ( strcmp( a, b ) == 0)  match_func() ; // true 
    else nomatch_func() ;
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Registered User
    Join Date
    Mar 2010
    Location
    Salem's Lot
    Posts
    19
    Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. issue with switch statement
    By bluetxxth in forum C Programming
    Replies: 14
    Last Post: 02-24-2010, 10:01 AM
  2. Usefulness of the "else if" statement
    By gn17 in forum C Programming
    Replies: 7
    Last Post: 08-12-2007, 05:19 AM
  3. If Else statement problem
    By doofusboy in forum C Programming
    Replies: 2
    Last Post: 11-09-2005, 07:18 AM
  4. if/break statement
    By Apropos in forum C++ Programming
    Replies: 7
    Last Post: 02-22-2005, 02:33 PM
  5. Uh-oh! I am having a major switch problem!
    By goodn in forum C Programming
    Replies: 4
    Last Post: 11-01-2001, 04:49 PM