|
Ahh I found the problem... The Iterator equals the actual element in the Vector not the element number! Well I think that's the error
|
|
|
|
|
Michael101 wrote: Iter is initialised at the beginning of the program like this ->
register vector::iterator Iter;
Why are you using register? I would definatly get rid of that at least for the time being.
I was asking about the initialisation of Counter. Where is it initialised?
Michael101 wrote: Have you ever had problems with Iterators after adding in a container to your vector?
I'm pretty sure adding a value to the end of your vector shuold not invalidate your iterators but you might want to see if you can verify that. Google should help. If you supect thats an issue add new values to a temp vector and then copy them to your real vector after you've finished iterating throught it.
The STL is birilliant but its not an easy beast to master. I sugest a couple of good books like Effective STL by Meyers
|
|
|
|
|
Effective STL by Meyers, yeah ok I'll buy it! Thanks for all your help, I have to leave this error for later but I'm sure I'll crack it soon. It's just finiky that's all.
Thanks for all your help, I appreciate it!
Michael
|
|
|
|
|
I have read your talk with Josh Gray, and I have only a few points to add.
a) Adding to a vector *will* invalidate all iterator in it. Not every time, but sometimes, and you cant control it. A vector is guaranteed to be in a continuous part of memory, and when it gets bigger, it is reallocated.
All Iterators are invalidated.
There are things you might try (reserve() ), but it will not work most of the time.
b) The register you put before the iterator-declaration is silly. An iterator is a class and will certainly not fit into a register.
c) in the for -loop, increment the iterator using the postfix-increment-operator: ++Iter .
Also,try to dereference the iterator as few as possible. You are getting a large overhead.
Your program will be much faster in release, and stop being unusable slow in debug mode (All with VS.NET 2005).
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Michael101 wrote: ...it gives me an assertion error.
What line of what file is asserting?
"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
|
|
|
|
|
could any one please tell me how to convert double to unsigned short
|
|
|
|
|
sure as you soon as you explain how you want to convert 8 bytes into 2
cout << "double: " << sizeof(double) << endl;
cout << "ushort: " << sizeof( unsigned short) << endl;
Resulting output
Console Research
double: 8
ushort: 2
|
|
|
|
|
Use the IBitSquisher interface!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How do you want the conversion to work? Do you want the result rounded? What should happen if the double is negative?
Steve
|
|
|
|
|
You can not convert. The only thing that you can do is to separate the four Bytes of the double into unsigned chars, and afterwards mount them another time.
This is what I have to do to get the "real" variables of a PLC. But its a shi...
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
|
This is what I have to do to get the real value of an analog input on a PLC.
The communication and reading function is BYTEwise, but reals in Step7 are 4 bytes. So I have to read indepentant bytes, separate some bits, and make the conversion to real using the formule of the IEEE.
BTW, thanks you a lot for the link. There is much better explained as in the help files of siemens
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hey Friends
Do we have a way to fill in values in the active window?
eg i have a html page & i want that an exe should fill values in edit boxes sort of
text then tab & then fill data ?
Regards
|
|
|
|
|
Can anybody help me to write a code to enhance an image.
I have a webcam captured image in BMP format(24bit or 16 bit RGB).Can the noises and distortions in the image can be cleared
|
|
|
|
|
Deepu Antony wrote: Can the noises and distortions in the image can be cleared
doubtful, we can't clear the noise and distortions in this forum.
|
|
|
|
|
|
Franz Klein wrote: the cause of the error.
It would appear you don't have required header files included properly.
|
|
|
|
|
Franz Klein wrote: name_extractor variable(name);
This looks like a declaration of a member function variable that takes one parameter of unknown type. If you really mean to declare a function, all parameters must have their types declared, i.e.
<br />
name_extractor variable (std::string& name);<br />
|
|
|
|
|
Franz Klein wrote: name_extractor variable(name);
name is not a type.
Steve
|
|
|
|
|
Having downloaded the 60 day trial version of Borlands Visibroker, I did get the first simple example working, but that was using the DOS Command windows.
I could not find a way to call the IDL complier and produce a solution in VS 2005.
I used the nmake to build the application on a DOS window launched from VS2005, otherwise the nmake was not known in the Borland DOS window.
Anyone have been here before?
Andy.
|
|
|
|
|
Dear Experts,
I am stuck up with a piece of code, which I am not able to break. Could you kindly help me out.
Situation:
I am trying to perform a string comparison between 2 variables, one defined as const TCHAR * and other defined as CS_CHAR, inside an Embedded SQL program in C++. My relevant code snippet is as below:
=====
short CSQLBox::fnTest(const TCHAR *varInput)<br />
{<br />
CS_CHAR szExtract;<br />
<br />
....<br />
<br />
if(strcmp(szExtract, varInput)==0)<br />
{<br />
...<br />
}<br />
}
=====
When I try to compile this code, the strcmp step is throwing an error "cannot convert parameter 1 from 'char' to 'const char *'".
I have tried typecasting parameter 1 as:
if(strcmp((const char*)szExtract, varInput)==0)
This way, the code compiles, but fails in runtime with unhandled exception error. I am unable to understand how to solve this issue.
Could anyone kindly offer me some suggestions.
cheers,
sanK
|
|
|
|
|
It looks like CS_CHAR is a single character not a string. If so then sending it to strcmp is not going to work.
|
|
|
|
|
sntnknd wrote: if(strcmp(szExtract, varInput)==0)
Try:
if (szExtract == varInput[0])
...
"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
|
|
|
|
|
Hello Everybody,
Thank you for your responses. I must say I had tried to be too specific and had missed out to mention that szExtract is an array. I am very sorry for this mistake. The actual piece of code goes like this:
<br />
short CSQLBox::fnTest(const TCHAR *varInput)<br />
{<br />
exec sql begin declare section;<br />
CS_CHAR szExtract[10];<br />
exec sql end declare section;<br />
<br />
szExtract[0] = _T('\0');<br />
<br />
....<br />
<br />
for( int j=0; j<5; j++)<br />
if(strcmp(szExtract[j], varInput)==0)<br />
{<br />
...<br />
}<br />
}<br />
I am sure I am making some serious mistake, for which this piece couldn't be compiled, but I am not sure what. Could you kindly suggest.
cheers,
sanK
|
|
|
|
|
Now you should be able to use strncmp() .
"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
|
|
|
|