Click here to Skip to main content
13,138,791 members (55,531 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I'm looking forward to finding the best solution for separation of integer,string and char.

char line[100];

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 22-Mar-13 7:57am
ThePhantomUpvoter 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170915.1 | Last Updated 22 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100