question about cin input ?



 DEVELOP > c-Plus-Plus > question about cin input ?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "mark"
Date: 19 Jun 2004 09:58:15 PM
Object: question about cin input ?
The input via "cin" is string. right ?
(say string s; cin>>s1; the input accepted via cin is now stored in string s)
How to convert this into integer ?
say user inputs 99. How to covert this string (99) into integer value of 99.
.

User: "John Harrison"

Title: Re: question about cin input ? 20 Jun 2004 12:31:34 AM
"mark" <markstone23@yahoo.com> wrote in message
news:5e41994c.0406191858.6ed7b9f7@posting.google.com...

The input via "cin" is string. right ?

Wrong

(say string s; cin>>s1; the input accepted via cin is now stored in

string s)
Right


How to convert this into integer ?

say user inputs 99. How to covert this string (99) into integer value of

99.
#include <stdlib.h>
int n = atoi(s.c_str());
There are many other ways as well.
john
.

User: "Victor Bazarov"

Title: Re: question about cin input ? 19 Jun 2004 11:32:15 PM
"mark" <markstone23@yahoo.com> wrote...

The input via "cin" is string. right ?
(say string s; cin>>s1; the input accepted via cin is now stored in

string s)


How to convert this into integer ?

say user inputs 99. How to covert this string (99) into integer value of

99.
Please search google groups for "convert string to integer C++"
(without the quotes).
.

User: "planetzoom"

Title: Re: question about cin input ? 20 Jun 2004 12:42:44 AM
(mark) wrote in
news:5e41994c.0406191858.6ed7b9f7@posting.google.com:

The input via "cin" is string. right ?

You can also input into an int:
int a;
cin >> a;
.

User: "Prateek R Karandikar"

Title: Re: question about cin input ? 21 Jun 2004 04:49:40 PM
(mark) wrote in message news:<5e41994c.0406191858.6ed7b9f7@posting.google.com>...

The input via "cin" is string. right ?
(say string s; cin>>s1; the input accepted via cin is now stored in string s)

How to convert this into integer ?

say user inputs 99. How to covert this string (99) into integer value of 99.

Why beat around the bush when you can directly input to an int?
int x;
cin>>x;
-- --
To iterate is human, to recurse divine.
-L. Peter Deutsch
-- --
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER