Scanf Problem!

Discussion in 'C' started by LuciaP, Aug 28, 2010.

  1. LuciaP

    LuciaP New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello1! First af all, excuse me for my bad english!

    I need to read user input that contains a certain command. My problem is that it depends on the command, the amount of strings i'll need to read. For example, there's a command with the following sintaxis:

    Command1 name = value
    and there are others like
    Command2 name

    and so on...
    Between the name of the command and the following text always a space occurs... in the other fields, there can be zero to any number of spaces, so a command like
    Command1 name = 45 is valid as well as Command1 name=45


    I'm having a lot of troubles with this.. i tried a lot of things but none of it worked.. i tried to google and learn how to user scanf properly but i just dont get it... so if you can help me, i'll appreciate an example and its explanations. I dont know if scanf can be use with variable amounts of variables, but thats not the main problem cause anyway i can scanf multiple times by checking the name of the command first. What i really dont understand is how ignore spaces.. how to ignore, for example, spaces, plus newline characters plus, for example, the "=" symbol...

    Well.. excuse me again, i dont know if someone will understand this but i had to try!! Thanks in advance!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice