Click here to Skip to main content
14,970,345 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I'm looking forward to finding the best solution for separation of integer,string and char.

char line[100];
gets(line);

user input 'there is a 1 room and 90 people'
then the program classifies like below and print them
integer = 1, 90
string = there is room and people'
char = a

I think it's possible to do it with using ascii code, but it has been still confusing.
How to solve it? need your advice
Posted
Comments
[no name] 22-Mar-13 14:04pm
   
Tokenize the string. The results that contain a single character is a char (according to your statement), the elements that are digits must be integers, right?, then the rest must be strings.

1 solution

It looks like you want a form of parser or at least a lexer. You can do this sort of thing with Flex and Bison which are free and easy to find with Google.

Yes all characters are of course stored as numbers in a computer and one of the most important mappings from numbers to characters is ASCII.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900