1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Scanf Problem!

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

  1. LuciaP

    LuciaP New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    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