Previous: 11.6 Exercises
Up: 11 String Processing
Previous Page: 11.6 Exercises
Write program drivers for each of the following. The driver should read appropriate data until end of file, call the functions described below, and print the results.
i ia wah hawaii
A valid token type is either an identifier, an integer, a float, an invalid, or an EOS, end of string. An identifier starts with a letter, and may be followed by letters and/or digits. An integer starts with a digit, and may be followed by digits. A float must start with a digit, may be followed by digits, may be followed by a decimal point, and may be followed by a sequence of digits. A character other than white space, letters, and digits is an invalid type token containing that one character. EOS type of token is returned when the NULL character is reached.
Write a program that reads in lines of input from a file, and use the above function to print out the tokens in each line until EOF.