Solved

Beginner: conversions

Posted on 2000-05-04
7
230 Views
Last Modified: 2010-04-02
cannot convert a string to a float.

CString name, val;

        for (int iii = 0; iii < 15; iii++)
        {
               
                name.Format("windspp %d",iii);
                val = app->GetProfileString("profile",name, "");
                        ppdata[iii] = "%f", val
        }

ppdata is an array of floats.
the registry entry that is read is a number 12,67 for example but i can only get it out as a string if i am right (?).
Now how do I convert a string to a float ??

could someone copy/paste a list of possible conversions here as i allways fall across one i cannot do.

thanks for helping.
0
Comment
Question by:peter_b
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 

Author Comment

by:peter_b
ID: 2777228
ppdata[iii] = "%f", val
this line is an error of course but thats what i would like to do...
0
 

Accepted Solution

by:
bxt earned 50 total points
ID: 2777431
Have you tried the atof function

ppdata[iii] = atof(val)
       

0
 

Author Comment

by:peter_b
ID: 2777718
well theres a loss of data from double to float but should be ok.
Can you gie me some other conversion possibilities I am allways hanging with this ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:bxt
ID: 2778000
atof should return a double so you shouldn't see any loss of data if you make your array an array of double.

There is also the strtod function

char *stringstop;
ppdata[iii] = strtod(val,&stringstop);

0
 

Author Comment

by:peter_b
ID: 2778070
okok great thanks but is there a list of all functions i can use somewhere ? the MS help is awfull...
0
 

Expert Comment

by:bxt
ID: 2778128
If you have MSDN go to the index tab and type 'data conversion routines' or
'string manipulation routines' for a full list of functions that should be of interest to you.

If you don't have MSDN go to

http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_crt_data_conversion.htm
0
 

Author Comment

by:peter_b
ID: 2778161
thanks you helped me alot !!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Fully specialized class template function 21 156
Getting IP address 8 123
C++ finding a sting in a char* string from a text file 3 137
computer science syllabus 3 115
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question