|
Ok then, program in machine code for 6 months and then quote me the same myth while keeping a straight face. I've heard this line so many times before and it always brings a smile to my face.
Steve
|
|
|
|
|
[PLEASE REMAIN GERMANE TO THE TOPIC -- THESE COMMENTS ARE FRUITLESS; PROGRAM IN WHATEVER YOU WANT I DON'T CARE. HECK USE MATCH STICKS -- JUST WANT TO UNDERSTAND THE SUBJECT I CREATED]
IN FACT, I FOUND A NICE E-BOOK, WROX - ISBN 1861001843 - Visual C++ Windows Shell Programming.pdf, SO IF YOU GUYS WANT TO USE THIS THREAD TO CONTINUE THIS IRRATIONAL DISCUSSION BE MY GUESS. I'LL BE BUSY LEARNING SOMETHING NEW. I'M UNSUBSCRIBING TO THIS THREAD SO I DON'T GET DISTURBED BY IT.
THANKS AND HAVE A NICE DAY!
C, C# and JavaME(J2ME) Programmer
|
|
|
|
|
|
I have been learning to code Overlapped I/O using completion port using winsock2 for the past few days and I still couldn't figure out why VS2005 complains about HEAP issues when I run the application in debug mode.
It's a console win32 project I've created using Visual Studio 2005 with SP1 running on a Windows XP Professional with SP2.
I'm pretty sure it's some sort of memory management error but I just couldn't see what's coming. Can someone take a look at my code and comment on it? Probably some fatal mistake I made.
TestServer02.zip
|
|
|
|
|
Zerox MXI wrote: complains about HEAP issues
Can you provide specific details?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes sir, it goes like this,
HEAP[TestServer02.exe]: HEAP: Free Heap block b6b9c0 modified at b6bab8 after it was freed
Windows has triggered a breakpoint in TestServer02.exe.
This may be due to a corruption of the heap, and indicates a bug in TestServer02.exe or any of the DLLs it has loaded.
The output window may have more diagnostic information
Nothing more than that except a read-only file was popped up... xutility that broke at line 166, I wonder what that is. Anyway, in the worker thread, as I stepped through the code at specific breakpoints I set particularly at WSASend and WSARecv, it seems to complain about this heap corruption when an overlapped received call is followed by an overlapped send call. I understand it is a call one after the other but this is just enqueuing the completion event in the queue watched by the OS kernel. And I have made sure that it gets a per I/O data structure for each client connected, and a separate buffer one for incoming and outgoing each.
|
|
|
|
|
When I click OK in the dialog box to create a new class in ClassWizard, I receive the following error message:
Unable to open the files <class>.h, <class>.cpp
and sometimes when i create or delete variables using class wizard the .cpp file is getting deleted.
i even scanned my system with Norton AntiVirus but there are no viruses.Please could u tell me how to solve this problem
|
|
|
|
|
The question you've posted may be the following reason:
1.your codes are in removable disk and the connection line is not connected very well;
2.your project files are all read-only;
If neither of above,you'd better reinstall your VC.
Later buggers harm more.
|
|
|
|
|
As u said the reason is none of above and i reinstalled vc but still these errors are comming.
|
|
|
|
|
I am using VC++ 2005 standard edition and tried using #include <windows.h>
in my project but there are a list of errors with the description:
"error C2872: 'IUnknown' : ambiguous symbol C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\unknwn.h "
I found that the windows.h file is in the C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK directory. The project has also included the $(VCInstallDir)\PlatformSDK\lib, \include and \bin lines in the project options window.
How to include windows.h correctly?
|
|
|
|
|
hi guys.
i have a simple problem but can't seem to find the solution anywhere..
background:
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. now given that, i want to add a null character, '\0', at the end of that char* that stores the double.
relevant code:
char* results_text[7];
results_text[0] = reinterpret_cast<char*>(static_cast<int>(m->total_time_taken));
how should i got about doing this? i am flexible in changing the method as long as the end result meets the following conditions: it is a char* holding the double value + a null character at the end.
thanks in advance.
--
dg
|
|
|
|
|
Why don't you just post your code to the Coding Horrors forum and be done with it!
Forget the code you have written, what are you trying to achieve?
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."
|
|
|
|
|
I am using GLUT to print out a char* to my window much like this:
renderBitmapString(45, window_height-90, 0.0, GLUT_BITMAP_HELVETICA_18, "testing...");
this function takes the char* and loops through it until the '/0' is seen and one-by-one uses the glutBitmapCharacter(void* font, int char) to print out the characters...
now if i cast a double into a char*, the '/0' is missing at the end so it results in a infinite loop and a runtime error...
i have tried to find a glut function that can print double to the screen but haven't succeeded. if you know an alternative way to do this or a solution to this problem, i would appreciate it very much!
thanks!
--
dg
|
|
|
|
|
an MFC solution:
<br />
double d = 1.234;<br />
CString str;<br />
str.Format("%f", d);<br />
renderBitmapString(45, window_height-90, 0.0, GLUT_BITMAP_HELVETICA_18, str);<br />
You can control the formatting of the double in the Format call. If you are not using MFC, look at sprintf, or there is probably a way of doing it with the STL string class.
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."
|
|
|
|
|
I used sprintf...here is the code:
sprintf(results_text[0],"%f",3.14);
renderBitmapString(205, window_height-90, 0.0, GLUT_BITMAP_HELVETICA_18, results_text[0]);
[ NO COMPILER ERRORS ]
However, during runtime, I get popup window saying:
Debug Assertion Failed!
Program:...
File: sprintf.c
Line: 110
..I'm lost..
--
dg
|
|
|
|
|
Did you allocate any memory for results_text[0]? If not sprintf will try to write to wherever the uninitialised pointer results_text[0] points to.
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."
|
|
|
|
|
This line allocates memory and was included when I was running the application:
char* results_text[7];
am i right? or are you talking about something else..
--
dg
|
|
|
|
|
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
|
|
|
|