Letting a string = an int

Hi guys, this might be some fundamental stuff but I just could not get around it and would appreciate some help.

1
2
3
4
5
6
int number = 0
char *string = "30.56";

number = string;

cout << string;


So my question for this particular questions is to why when I cout my variable 'number', it only gives me 30 instead of the full 30.56. Thanks in advance for anyone taking their time replying to this. :)
Well, aside from the fact that assigning your string to an int like that is dodgy, how many integers do you know of with fractional parts..?

http://www.cplusplus.com/forum/articles/9645/
Last edited on
And notice that article is outdated as we now have std::to_string and std::stoi/std::stod/... family of functions.
indeed.
I see how it is now. Thanks for the help guys. Appreciate it!
Topic archived. No new replies allowed.