I am supposed to get an input line that can be in of any of the following formats:
This is beyond the scope of scanf and friends, to be perfectly honest; in addition to the answers of "write your own simple parser", you could to invest in yacc to parse the grammer (the lexer is left as an exercise for the reader):
line: oneword | twowords | threewords;
oneword: word;
twowords: word word;
threewords: word word word;
word: STRING;
This may be overkill for you here, but if you ever need to parse even more than marginally complex formats, it's a lifesaver.