How does C handle converting between integers and characters? Say you’ve declared an integer variable and ask the user for a number but they input a string instead. What would happen?
How does C handle converting between integers and characters? Say you’ve declared an integer
Share
The user input is treated as a string that needs to be converted to an int using atoi or another conversion function. Atoi will return 0 if the string cannot be interptreted as a number because it contains letters or other non-numeric characters.
You can read a bit more at the atoi documentation on MSDN – http://msdn.microsoft.com/en-us/library/yd5xkb5c(VS.80).aspx