cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Delimiting a string
Delimiting a string
Mar 1, 2011 at 6:57pm UTC
Janman
(16)
Hey
I'm new to c++, and I would like to what is the most simple way to delimit an input from the user?
fx, user types in
"20m".
and the program saves the "20" in an int and the "m" in a char, but how would you do that?
Mar 1, 2011 at 7:16pm UTC
hamsterman
(4538)
if you do cin << with a numeric variable (int, float, etc.) it will stop after the last number.
so
1
2
3
int
i;
char
c; cin >> i >> c;
should be fine.
Topic archived. No new replies allowed.