Thread: Question scanf (2 conditions)

  1. #1
    Registered User
    Join Date
    Oct 2016
    Posts
    2

    Question scanf (2 conditions)

    Hi everyone,

    I am new to C and I have a question about the scanf function.
    I want to output a certain code, but only if the first input (scanf) is specific number/letter/word/sentence and the same for the second unput (scanf).

    For example:
    A certain code only works if (the first input = '3A') and (the second input = '56B').

    Could someone tell me how to do this or give me a really simple example.

    Thanks in advance!

  2. #2
    Registered User cstryx's Avatar
    Join Date
    Jan 2013
    Location
    Canada
    Posts
    123
    Read the data then use strncmp? If it doesn't match then don't do anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. newbie question - if statements without conditions
    By c_h in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2008, 10:42 AM
  2. scanf question
    By jebster in forum C Programming
    Replies: 10
    Last Post: 10-26-2003, 07:39 AM
  3. Scanf Question
    By shiyu in forum C Programming
    Replies: 4
    Last Post: 01-31-2003, 08:48 AM
  4. scanf question
    By pkananen in forum C++ Programming
    Replies: 4
    Last Post: 02-17-2002, 08:18 PM
  5. scanf question
    By dbaryl in forum C Programming
    Replies: 1
    Last Post: 11-02-2001, 02:38 AM

Tags for this Thread