|
Hi,
I just tried with GetLastError( ) function, and found that the error number is 998 i.e. "Invalid Access to memory location". Its name is "ERROR_NOACCESS"
Thanks n Regards,
Amit.
|
|
|
|
|
My first guess would be that something got stepped on in either your address space or in the heap. ERROR_NOACCESS actually means that an exception (Access Violation) was encountered internally within an underlying function.
Try using that debug function I posted earlier and see if it can detect if anything is wrong. Not all overruns are detected by the debug heap, especially if the overrun happens AFTER the memory is deallocated.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Malloc or new doesn't fail unless your system is out of memory (which I doubt).
There are two things that can be going on:
1. Prior to allocating the memory, you have managed to trash your memory heap thus causing the call to fail. Try using _CrtCheckMemory before and after the call to malloc.
2. The malloc is actually working just fine, but due to other bugs in your code, the routine is failing and you are misdiagnosing the problem as an allocation failure. I see this happen very often. Usually by people who can't believe their software has bugs so they blame the compiler. However, experienced programmers do this to.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Tim Smith wrote:
Malloc or new doesn't fail unless your system is out of memory (which I doubt).
Or you are trying to allocate too much memory...
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Normally allocating memory is not affected by threads, since the whole thing is synchronized with a semaphore (critical section).
Try single-step debugging to check if the error comes from CRT code or from windows itself.
Don't try it, just do it!
|
|
|
|
|
Alexander M. wrote:
Normally allocating memory is not affected by threads, since the whole thing is synchronized with a semaphore (critical section).
[Pedantic Hat On]
Technically, it is affected, and it is because of the Critical Section used to synchronize access to the heap in the default runtime memory allocator. If multiple threads are abusing the heap, they will lock each other out from time-to-time, which will hinder performance.
[Pedantic Hat Off]
That is actually one of the reasons developers sometimes see a dramatic decrease in performance when they start using multiple threads - bad memory practices.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Tip for new SUV drivers: Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Hello,
I was wondering, is there a way to retrieve the key associated with a value when you have only the iterator?
Lets take the following code example:
typedef std::map<int, std::string> MyMap;
MyMap map;
for( MyMap::iterator iter = map.begin();
iter !< map.end();
iter++;
{
}
Is this possible and if yes, how can I achieve this?
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I see now that a map iterator contains both the key and the value in a pair... What a dumb question it was indeed...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
<br />
typedef std::map<int, std::string> MyMap;<br />
MyMap myMap;<br />
<br />
for (int i=0; i<10;i++)<br />
myMap[i] = "Test";<br />
<br />
MyMap::iterator myIterator;<br />
<br />
for(myIterator = myMap.begin();myIterator != myMap.end();myIterator++)<br />
{<br />
int key = myIterator->first;<br />
string value = myIterator->second; <br />
}<br />
Hope this helps.
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Nilesh K. wrote:
myIterator->first;
Thats what you get for not paying attention...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
An iterator over a map contains a std::pair object. You can access the current map key by using iter->first, and the current map value by using iter->second.
Regards,
--Mike
|
|
|
|
|
Hi guys,
I tried to use POST to send string to a text box in the website.
But it return me an error, said "The server unable to implement the request"
.
What goes wrong? Need help and advice
thanx
|
|
|
|
|
Try to ask this question in the web development forum! Here most people don't know or know to little about webdev to answer you unclear question. Even if someone knows it, I doubt that he / she will answer.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
dex_ter11 wrote:
I tried to use POST to send string to a text box in the website.
are using Visual C++ post data or some other Language
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
sorry for the unclear information. What should i do, to send a string to a text box of a html page using visual C++?
thanx
|
|
|
|
|
Then you have to get the Current Object of the INTEREXPLORE WINDOW i.e. IWebBrowser control.
using IWebBrowser control you can retrieve whole HTML page present in the BROWSER, Remember Browser can only display the HTML pages, .ASP are just HTML PAGES developed at Runtime by Server.
Now IWebrowser::get_Document() retrieve IHtmlDocument2 interface and manaully parse the HTML page to reach your INPUT box and put you value into it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I searched for my problem and found other who had it, but didn't find an answer.
I am getting "LNK2001: unresolved External Symbol" in my MFC Dialog Box Program. Here is my situation:
The unresolved symbol is a CString that belongs to my Edit Control. It is declared as a Public variable in my main dialog class in "dialog1.h". Now this is being used within a static member function (in the same class) which is declared in "dialog1.h" (The function is a Seperate Thread being called by AfxBeginThread() from "dialog1.cpp". The actually Function however is in "dialog2.cpp". The CString is being used within this function in "dialog2.cpp". Both "dialog1.cpp" and "dialog2.cpp" have includes for "dialog1.h", so I do not see the reason why this is happening.
I thought of making this CString external, but I am not sure how to do it when it is a member of a class.
Rundown:
CString Variable: Declared in dialog1.h and initialized in dialog2.cpp
static member function: declared in dialog1.h and initialized in dialog2.cpp
Static member function is called from dialog1.cpp using AfxBeginThread() API.
If anyone has any suggesstions that would be great.
|
|
|
|
|
you can not access non-static members of a class within a static function.
you can only access that member through an instance of the class passed as a parameter for example.
Greetings,
Davy
|
|
|
|
|
So if I understand correctly, you have a static CString member variable in your edit control, which is the unresolved external symbol right?
If this is the case, your code of your edit control should look like this:
class CMyEditCtrl : public CEdit
{
public:
static CString st_sSomeString;
};
if this is the case, your problem is that you didn't declare the static variable. In MyEditCtrl.cpp, add the declaration like this:
CString CMyEditCtrl::st_sSomeString = "";
That should resolve your problem. If the above is not your case, try to clearify your problem, by posting some code snippets..
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thank You Bob, This did solve my problem
However, now I am not getting output to my edit box. Here is what I am doing:
static CString mystring;
CProgressCtrl m_sigstr;
UINT getstring[4];
m_string.Format("%d",getstring[1]); // Format m_string with a decimal Number
static UpdateData(FALSE); // Send New string to Edit Box
m_sigstr.SetPos( getstring[1] ); // Set Position of Progress Bar according to getstring value
getstring [1] both holds the value I want to output to the edit box and use to reposition the progress bar. From a debug I did, it is not working on the progress bar as well as not outputting the value to the Edit Box.
|
|
|
|
|
CNewbie wrote:
m_string.Format("%d",getstring[1]);
static UpdateData(FALSE);
m_sigstr.SetPos( getstring[1] );
Consider that code fragment. I thought about the following things the moment I say it:
<list>What is that static word doing there?
Why do you call UpdateData(FALSE); in the middle of your updating process?
If you look up the UpdateData() function in MSDN, you see that this calls DoDataExchange() which synchronizes the data of all the controls on your dialog. Knowing this, you should move the call to UpdataData(FALSE) down the bottom of the function. After this, all the changes will be made visible.
Hope this helps
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Thanks for responding. I understand your logic, but the reason why I cannot do that is because that function loops over and over again every 500ms until a condition is met and then it exits. The Edit control as well as the progress bar will update at the bottom of every iteration. So you see if I put the UpdateData() at the end of the function, the edit box would never update until the function exited and that would defeat the whole purpose of what I want to do here.
|
|
|
|
|
Than put the call to UpdateData() after you update the progress bar instead of before it...
Sometimes, a little bit of experimenting will do magic for you...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Also If I dont put "static" in front of UpdateData(FALSE), I get this error:
error C2352: 'CWnd::UpdateData' : illegal call of non-static member function
|
|
|
|
|
I've never seen that before... It doesn't seem like legal C++ to me, but if the compiler accepts it, I must be wrong...
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|