| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Converting Strings To Integer In Linked List
Does anybody know how I could get a string value from a file convert it to integer so I can do calculations and stuff, any help will be greatly appreicated
This is the code I got so far temp_totalprice1=atoi(Stock.RetailPrice); temp_quantitysold1=atoi(temp_quantitysold); temp_totalprice1=temp_totalprice1*temp_quantitysol d; On the above code it doesn't assign the value of (Stock.RetailPrice) to temp_totalprice |
|
#2
|
||||
|
||||
|
Print out the string value of Stock.RetailPrice, it's possible it's empty becuase of faulty file handling.
Also ensure that "RetailPrice" is a valid character pointer in the "Stock" object, and not accidentally just a normal character or something.
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips. ![]() |
|
#3
|
|||
|
|||
|
Quote:
Yes... atoi should work if you have a string that contains only numbers. I think it quits on the first occurance of a non numeric character Perhaps you could post your class definitions in a code block? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Converting Strings To Integer In Linked List |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|