I want a code that can convert floating/double value into string/char array(char arr[]) and also it can be run on Boreland C++ 5.02
Here I've a code but it doesn't show all the numbers. Instead, it's showing in exponential form which I don't want!!
int main() { char* str = new char[30]; float flt = 2.4567F; sprintf(str, "%.4g", flt ); cout<<str<<endl; //Exponential form even after 6 digits without decimal return 0; }
I have a problem in using ATL 7.0 string conversion macros.
My codes looks like this, which uses ATL 3.0 string conversion macros in the past:
Void Myfunc() { USES_CONVERSION;
LPSTR lpszA; LPWSTR lpszW; If (...) { CString strText; If (...) { If (bUnicode)
[Code]...
But since 3.0 macros do not support large strings, I want to switch to 7.0 macros, but have problems. Based on the [URL]... samples, I should declare CT2A pszA(strText) or CT2W pszW(strText) within the if and else bodies, as below:
However, in such a case, after running to the codes using lpszA or lpszW, both CT2A and CT2W will be destructed so lpszA and lpszW will be invalid. How to solve this problem?
I'm trying to understand why a conversion from a byte array (unsigned char) to a double works when done one way and not antoher.
In the example code I test by hard coding an unsigned char array of the same bytes that the double consists of.
When I copy the bytes to a long long and cast to double the result is not the original double but if I use a struct the bytes can be set and the conversion happens.
Seems to me that both ways should work. I'd just like to know what is going on with the "struct way" that makes the conversion correct. I see in debugger that the bytes in memory are the same for piAsLong and u.bytes.
My compiler is VS 2012 and a long long and double are both 8 bytes (tested with sizeof). This is learning activity only.
Code: #include "stdafx.h" #include <iostream> #include <iomanip> using namespace std; union { double d;
I have a question on conversion between char & string. I have cut & pasted the part of the code from my C++ code and my function "decryptPwd" uses C style code with "char" etc.
I need to pass a string (mypwd) somehow to this function after conversion & then compare it to another string (newmypwd).
I tried - "decryptPwd(mypwd.c_str())==newmypwd.c_str()" but it did not work.
.. #include <string> .. char* decryptPwd(char hash[64]); main () { string mypwd; string newmypwd; if (decryptPwd(mypwd)==newmypwd)
I have this old c function that takes as an argument a char*. but my app is written in cpp so i used std::string to store my strings. to pass a char * to the function i tried :
Code: char *input = new char[args.i.length() + 1]; strcpy(input, args.i.c_str()); and then Code: function (input); and function ( (char *)input);
But I still get this warning message which i would like to fix:
Warning: deprecated conversion from string constant to "char*" [-Wwrite-strings]
following code that I'm reading out of the book "The C++ Standard Library".
class C { public: explicit C(const std::string & s); // explicit(!) type conversion from strings. ...
[Code].....
Now I understand that they are saying that an explicit conversion isn't allowed but what I don't understand is what explicit conversion would be happening if there was one allowed.
Specifically I don't understand the const C & elem syntax. How does this work since the collection holds strings. What would be the syntax for how this:
const C & elem
gets strings. I was thinking it was a class reference that someone how converts to a constructor function pointer or something but i'm really confused.
I'm trying to make OBJ converter. The file structure of which I am trying to convert is an XML structure. Here's an example. I currently have a lua script that does this for me. But it always crashes on big objects. It's for a game called "ROBLOX" The only information I need to convert is.
<int name="BrickColor">194</int> <-- Brick Color <CoordinateFrame name="CFrame"> <-- Position <X>0</X> <Y>0.600000024</Y> <Z>0</Z>
And
Vector3 name="size"> <-- Part size. X>1000</X> Y>1.20000005</Y> Z>1000</Z>
Here's the lua script. [URL] .....
This currently grabs all of the ClassNames in the place and converts them to OBJ wavefront gemotry.
So, I'm supposed to do : Create a function with unlimited number of arguments, which forms a dynamic string based on the following form (%d, %s, %f, %lf, %c), with the following prototype:
char*create(char*form, ...);
The function is supposed to have the following output:
create("Peter is %d years old and is in %s-%c class.",7,"second",'A'); -> Peter is 7 years old and is in 7-A class. create("His GPA is %lf.",4.96); -> His GPA is 4.96. create("His favourite subject is math!"); -> His favourite subject is math!
The part with %d and %s string was not that hard, but now I'm supposed to convert %f and %lf to string, I've tried using sprintf but I've had no luck so far, another problem is the fact that I've gotta use lists to complete the task. I've been trying to convert float to string for the past 2 hours, but I'm drawing a blank now.
I'm trying to find a way to accuratley convert a double in the form of a bank account number stored in a file into a string representing the number returned by a file.
i think i need to convert a double to a string, we are working in visual studio doing a program. when i run the calculator i'm not getting the answer i need instead its giving me 0.0 when it should be reading 0.5, here is the code i'm using
{int width; int height; int area; double gop; String ^strWidth; String ^strHeight; String ^strArea; String ^strGop; strWidth=width1->Text;
I have a project that is essentially a hot pot of C/asm (naked functions etc). The code gets injected into another EXE. It works fine when compiled in Visual C++ 6 but when compiled in Visual Studio 2008 it compiles fine but falls over in use.
Are there certain settings I need to look out for? I have optimization disabled and as far as I can tell the command line options for compiler/linker are the same (given the differences).
I have opened both builds in IDA and the 2008 build has more import and offset jumps are in different places.