Advertisement Jump to content
Sign in to follow this  
Ultra The Vampire

conversion problem

This topic is 4900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am trying to retrieve a number from a text file (ASCII text) i need to convert the string to a float or int to use in a numerical function. problem is i get this ------------------------------------------------------------------------------ c:\coding\irrlicht\ice\ICE_3.0\ICE_3\src\Demo\GameStates\gs_DemoFakeGame.cpp(68) : error C2440: 'type cast' : cannot convert from 'char [100]' to 'irr::f32' There is no context in which this conversion is possible ------------------------------------------------------------------------------- irr::f32 is a typedef for float. i tried this.... ---------------------------------------------------------------------- irr::f32 PD_Entity_Loader::Get_X_Position() { ifstream Entity_Definition_File ( "Entity_List.txt" ); char Entity_Content_Holder[100]; getline(Entity_Definition_File, (string)Entity_Content_Holder, '\n'); return((irr::f32)Entity_Content_Holder); } --------------------------------------------------------------------- is there a way i can retrieve the value in the text and still get it as a float for my operation?

Share this post


Link to post
Share on other sites
Advertisement
You realize that >> works with ifstreams right?

ifstream Entity_Definition_File ( "Entity_List.txt" );
irr::f32 temp;
Entity_Definition_File >> temp;
return temp;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!