Java-Stdin.readInt (), Is there an equivilant to this in C?
Author |
Message |
JMG
|
Posted: Thu Sep 18, 2008 3:59 pm Post subject: Java-Stdin.readInt (), Is there an equivilant to this in C? |
|
|
hey yall. I'm fairly familiar with Java but am currently trying to learn C. Is there a command in C similar to the Stdin.readInt() in java? I'm just basically trying to get user input and store it as a variable. Any help would be appreciated. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Thu Sep 18, 2008 5:50 pm Post subject: Re: Java-Stdin.readInt (), Is there an equivilant to this in C? |
|
|
Do a web search on scanf(). |
|
|
|
|
![](images/spacer.gif) |
md
![](http://compsci.ca/v3/uploads/user_avatars/1849317514ed6c4399768d.png)
|
Posted: Thu Sep 18, 2008 10:17 pm Post subject: RE:Java-Stdin.readInt (), Is there an equivilant to this in C? |
|
|
scanf is a horrible function, but it does work.
Your best bet is to read in a string, then convert it into the format you want with strto* all of which return error codes for almost every error you might find. |
|
|
|
|
![](images/spacer.gif) |
|
|