954,480 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

warning C4244: 'argument' : conversion from 'double' to 'char', possible loss of data

Can anyone help me convert char to double. Yes, I tried casting, it did not work. Anyway, this is the problem, the variable is declared as type double in the struct(database structure). However, it is defined as type Text in the class I'm modifying.

The variable in the class I'm using must remain that type because it is used by other functions in the class. Please help

Nis

webempress
Newbie Poster
6 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

Type Text is probably a string of some sort, rather than type char per se'. This then becomes similar to converting type int to a string, whcih may be in a FAQ somewhere. In any event, I'd try using a stringstream (C++ style) or sprintf() (C style) to convert the double to a string and then convert the string to type Text, if necessary.

Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
 
Can anyone help me convert char to double. Yes, I tried casting, it did not work.

While you're learning to program don't splash casts all over the place to disguise your own errors. http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.1

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Thanks for the advice and I will not bash casting (cause it does and excellent job) but for this program its not the solution. It solves the run time warnings but logically, it does not generate the likely response.

Do you have any more ides.

webempress
Newbie Poster
6 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 
Thanks for the advice and I will not bash casting (cause it does and excellent job) but for this program its not the solution. It solves the run time warnings but logically, it does not generate the likely response.

You cannot cast a string to an integer or floating point value or vice versa.Do you have any more ides.Uh, yeah. Follow the link I posted.Thanks for the advice and I will not bash casting (cause it does and excellent job)List your top 5 things that cast does an excellent job at. I'd speculate that 3-4 of them are used incorrect. (Of course I'd be happy to be wrong.)

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You