|
Cedric Moonen wrote: he is called Mr. Debugger
lol ....
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Invalid memory access. (buggy pointer?)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Anandi.VC wrote: First-chance exception in DWB.exe (OLEAUT32.DLL): 0xC0000005: Access Violation.
Could any one tell me the meaning of the above sentence ?
can be invalid pointer access. and what is First-Chance exception? When Exception Occurs debugger get notified and this first pass is called "First-Chance Exception", the debugger can then decide to pass to application to run normally if the exception was not handled by the application then the debugger gets notified again and is "second-chance exception" where the application must crash.
[First and second chance exception handling^]
Several cases the first chance exceptions don’t necessarily need to be dangerous and does not mean application's code is not proper.
for instance the following code causes first chance exception message to be written in output window
try
{
throw 100;
}
catch (...)
{
cout << "exception";
}
try
{
int *ptr = (int *)0x01;
*ptr = 1000;
}
catch (...)
{
cout << "exception";
}
but the application handled the exception, so you don't get second chance exception.
This may not be a buggy code, but if it is buggy you cannot find the exact position of exception as the default settings of the debugger won't break execution at first-chance exception, you can enable the debugger to break at First -chance Exception so that you can get the exact position. say in VS2005, "Debug->Exceptions: then check mark exception in the list". I don't remember in VS6.0 (its time to throw these old stuff dude )
modified on Thursday, May 8, 2008 11:05 AM
|
|
|
|
|
Rajkumar R wrote: try // SEH is enabled
{
int *ptr = (int *)0x01;
*ptr = 1000;
}
catch (...)
{
cout << "exception";
}
This construct is non-standard. The C++ standard states that catch can only catch exceptions explicitly thrown via the throw keyword. Microsoft got it wrong but later added the /EH[^] switch to select the old non-standard behaviour or the behaviour mandated by the C++ standard.
Steve
|
|
|
|
|
Yes steve, you are correct that's "Microsoft specific" .
5! for the description for what i mentioned by the comment // SEH is enabled.
|
|
|
|
|
Thank u very much for your clear explanation.
i would love to switch to the latest version of VC but my work place wont permit it !
|
|
|
|
|
Hi all,
I have a buffer that starts with a couple of null characters before the actual data starts, and I'm trying to copy the contents of the buffer to another buffer, without any success. I know memcpy will work but it will also wipe the data that is already in the buffer. What can I do to copy the contents of the buffer to the other buffer ??
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I know memcpy will work but it will also wipe the data that is already in the buffer.
What do you mean by that ? It will only make a copy of what is in the orignal buffer without modifying it.
|
|
|
|
|
OK, consider the following:
#include <stdio.h>
#include <string.h>
int main ()
{
char str1[]="Sample string";
char str2[]="Another string";
memcpy (str2,str1,strlen(str1)+1);
printf ("Contents of buffer2:",str2);
return 0;
}
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
What do you need to do? Do you need to concatenate buffers?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I don't see what you mean because your first explanation was a bit confusing. Of course that memcpy will erase what is in str2 because you want to copy the contents of str1 into str2. Which behavior are you looking for ? Your str2 can't hold its previous value and the new value.
I'm very confused as to what you are trying to achieve here
|
|
|
|
|
Programm3r wrote: char str1[]="Sample string"; char str2[]="Another string"; memcpy (str2,str1,strlen(str1)+1);
don't you haven't heard about pointer arithmetic.
memcpy (str2 + strlen(str2), str1, strlen(str1)+1); provided destination buffer has enough space.
anyway for string concatenation you don't need this if its raw buffer.
memcpy (byDestBuffer + dwCntDataInDestBuffer,
bySrcBuffer, dwCntDataInSrcBuffer);
dwCntDataInDestBuffer += dwCntDataInSrcBuffer;
|
|
|
|
|
guess not ....
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
you said you want to concatenate buffers, with memcpy you said you have issues i don't see any issues whether its string or raw buffer and such a simpler question here.
|
|
|
|
|
What exactly do you need to do?
i.e. What is the input and what is the expected output?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I'm receiving a minutiae buffer from a biometric reader, and there is alot of null charaters in the buffer that I received. I then want to concat it to another buffer. And that is aboput that ....
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Programm3r wrote: I then want to concat it to another buffer. And that is aboput that ....
Ooookayy, you should have said that in your first message, it would have made everything a bit clearer . I suggest you use a std::string instead of plain char arrays, it is possible to store null characters and it is much easier to do string concatenation.
|
|
|
|
|
Cedric Moonen wrote: I suggest you use a std::string instead of plain char arrays,
Only if he was using C++.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: Only if he was using C++.
Errr.. yes. But as the title of the message board is Visual C++ and that he didn't specifically said he was working in C, I concluded he was using C++ (yeah I know, jumping a bit too fast on the conclusion )
|
|
|
|
|
Actually, I had been stupid enough to use things like cout in the solution I provided to him, even though I assumed it was C (just modified it to use printf ). We're addicted to C++, you see.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh R Subramanian wrote: We're addicted to C++
What are these two fancy symbols following the only Real Man's Language?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: What are these two fancy symbols following the only Real Man's Language?
Symbols of evolution.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Could you make a detailed example (of what you have and what do you want to obtain)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
memcpy should work. Anyways, I want you to get an idea of what, this problem is all about. If you know the length of the string, then something like this might work for you. This is just a rough idea, you might want to make it better and more secure:
#include "stdio.h"
void strcpyEx(char* dest, const char* source, int iLen)
{
int i;
for(i=0;i<iLen;++i)
{
dest[i] = source[i];
}
}
int main()
{
char a[] = {'\0','\0','H','i','\0'};
char b[5];
strcpy(b,a);
printf("Attempting strcpy... b[3] is %d\n",b[3]);
strcpyEx(b,a,4);
printf("Attempting strcpyEx... b[3] is %d\n",b[3]);
return 0;
}
|
|
|
|
|
Some formatting reviewal needed.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|