|
moonraker928 wrote: char* results_text[7];
allocates an array of 7 character pointers. If you are trying to allocate a buffer for characters:
<br />
double d = 3.14;<br />
char text[128];<br />
sprintf(text, "%f", d);<br />
Be careful with sprintf() that you don't overwrite the buffer - there is a safer version in VS20058 - sprintf_s(). Making the buffer only 7 characters long needs care, I've allocated 128 bytes to be safe.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
ok i solved the problem - i had to initialize the char as char str[10] instead of char* str.
what a silly reason ... for wasting all that time..
--
dg
|
|
|
|
|
If you are allocating such a short array you either have to be very careful that sprintf does not write past the end of the array (remembering the null terminator) or use the safe version. If sprintf writes past the end of the buffer you will get bugs that can be very hard to track down.
I can't find the limit of width using %f, but a quick test with printf("Pi = %f", 1000000000000*pi) gives "Pi = 3141592653589.793000" showing that the %f specifier can print 20 characters at least. So printing using %f to a buffer of length 10 using sprintf is dangerous at best.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
|
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
You need to allocate memory first:
results_text[0] = new char[6];
sprintf(...);
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
moonraker928 wrote: i have a double and an array of char*. i used reinterpret_cast to convert the double into a char* and then stored it in a particular index.
Ouch.
If there was a programmer penalty box, you would be sent to it, and not allowed to use
reinterpret_cast for 2 months
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Haha. Yes, I read about the dangers of using that - now I use sprintf(..) thanks to you guys!
--
dg
|
|
|
|
|
Error: Could not generate command line for the 32-bit C/C++ Compiler for 80x86 tool.
Any idea why this happens?
Note: I've enough disk space.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
What if you restart VC? Rebuild too.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: What if you restart VC?
As simple as that! I was not even patient enough to test this. I closed the workspace and reopened and got the same error again. Just closed the IDE and opened again. It's fine now. And sorry for the disturbance!
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
In VS 2003, they fixed it - the IDE "closes" for you (with a friendly message asking if you want to
report the problem), saving you the trouble LOL
(I've only had 2005 crash once since I started using it full-time a few weeks ago)
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
heh,
VS2002 does the same thing. Closes for you when it detects a problem. Unfortunately I am still maintaining a single project in which the high level decision makers will not allow me to upgrade the project to VS2005.
Maybe I'll ask again next year when Orcas comes out.
|
|
|
|
|
Randor wrote: still maintaining a single project in which the high level decision makers will not allow me to upgrade the project to VS2005
Sounds scary. What are you going to do if VS2002 takes a dump? Make sure the decision makers are to blame.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
I'm working on a project,and one of the requirements is to draw one of the icons
in a different angle every time that the angle is updated.
Is there any way to rotate the icon,or shall I use a bitmap instead of icon and blit the bitmap's pixels by myself(which can consume a lot of CPU?)?
With best regards,
Eli
|
|
|
|
|
The better way is to have different[rotated,straight & all] icons/images in the resource and use them at the same place.. that would give you an "animated" effect rather than manipulating it at runtime.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
Hi VuNic,
Thanks for your quick reply.
My problem is that I need to rotate the icon is 360deg with resoultion of 0.5deg(i.e 720 icons...).
I'm sure that there is a way to rotate an icon during runtime,but I can't find it...
With best regards,
Eli
|
|
|
|
|
0.5 degrees? Clickety[^] This might help you.
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
Thanks again,
I read this article(and others...),but the problem is that each one of those projects
runs all over the pixels of the bitmap,which consume a lot of CPU...
Thats why I thought the rotating an icon will be much more efective...
Thanks anyway...
Eli
|
|
|
|
|
Welcome, we'd wait for an image specialist here
He's become a household word in the Lounge. A whole new phraseology has evolved. Post a link or reply with a smiley and rose, and you've made a "Satipsism". So what? It's an interesting thing about the Internet, the evolution (as in change, not progress) of tone, quality, terminology, etc.
-Marc Clifton.
Best wishes to Rexx[^
|
|
|
|
|
How big is the icon? GDI+ would make it simple to code.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
eli15021979 wrote: 0.5deg(i.e 720 icons...)
What is "720 icons"?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Mark Salsbery wrote: What is "720 icons"?
VuNic wrote: The better way is to have different[rotated,straight & all] icons/images in the resource and use them at the same place.. that would give you an "animated" effect rather than manipulating it at runtime.
I need to be able rotate the icon 360 degrres , with resolution of 0.5 degrees , so if I want to
use Vunic's way , I need total of 720 icons (2 icons per 1 degree...).
I'm preety sure that there is a way to rotate the displayed icon,but still,I can't find
any article or post in the forum for the related issue...
Maybe you can help me???
With best regards,
Eli
|
|
|
|
|
Whats wrong with the link to the code I posted earlier?
-Randor (David Delaune)
|
|
|
|
|
Hi David,
I just finished reading this article,and it seems preety good.
I will give it a try...
But still,isn't any way to rotate an icon?
Thanks anyway for your quick and helpful reply.
With best regards,
Eli
|
|
|
|