Jump to content
  • Advertisement
Sign in to follow this  
Gnark

String question

This topic is 3705 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

Ok I have this problem: I have a string: string a = "1.0, 0.0, 0.0"; I need to use this string in a method: Point3D(a); And this is how the method is used: Point3d(float x, float y, float z) Obviously I can't do Point3D(a), but I have no idea how to fix this. Reason I need this is because I'm reading from a file. Please help!

Share this post


Link to post
Share on other sites
Advertisement
What language?

Assuming C++, why don't you just read in the values from file as floats?


std::ifstream infile(filename);

float x, y, z;
infile >> x;
infile >> y;
infile >> z;

Share this post


Link to post
Share on other sites
What programming language are you using?

Assuming C:

fscanf (fp, "%f %f %f", &float1, &float2, &float3);

Assuming C++:

inFile >> float1 >> float2 >> float3;

Share this post


Link to post
Share on other sites
Just a note to fpsgamers post that if you are going to use a function like fscanf and scanf() microsoft has deprecated them and replaced them with newer safer functions they are virtual named the same and just prefixed like so s_sfscanf() or its post fixed i am fairly certain it is prefixed.The s_ i belive stands for safe just search on msdn.com to be sure. For the most part the functions have stayed unchanged as for arugments and work the same its the internals that have been made safer.

Regards Jouei.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!