|
I dont use VC.NET just plain V6.00 I look at these
http://www.codeproject.com/system/serial_com.asp?target=Serial%7CPort
there are a lot of examples of how to use the serial port, in the end you just use it the same as reding and writing files.
|
|
|
|
|
I have an iterator that is pointing to a certain element. I want to overwrite this element with the next one following it.
*I is the current element. But if I do ++I to get to the next element I lose my place....
I dont think *I = *(++I) is quite going to do it. (what would this do anyways? )
thanks,
ns
|
|
|
|
|
|
|
Or: *I = *(I + 1);.
--
Unser Tanz ist so wild! Ein neuer böser Tanz.
Alle gegen Alle!
|
|
|
|
|
Only if I is a random-access iterator.
|
|
|
|
|
Yes, you are right. I thought forward iterator would be ok. I guess one will have to use std::advance instead then. But I'll have to copy the iterator, as std::advance mutates the iterator (passed by reference)
But I guess one could always do
template <typename Iterator, typename Distance>
Iterator my_advance(const Iterator& i, Distance d) {
Iterator tmp = i;
std::advance(tmp, d);
return tmp;
} and then
*I = *(my_advance(I, 1)); If the compiler is smart and inlines the function, there's no overhead penalty.
--
Unser Tanz ist so wild! Ein neuer böser Tanz.
Alle gegen Alle!
|
|
|
|
|
This is really a newbie question, sorry about that:
What does this mean?
<br />
clock_t start, finish;<br />
double duration;<br />
<br />
duration = (double)(finish - start) / 1000; <br />
Why do we put the data type in the braces?
start and finish are clock_t data type, but
the duration is a double tpye. Is it some
kind of conversion or what?
What other situation do we also need to do that?
Thanks
|
|
|
|
|
its called as the type conversion.
Since you use the 'equal to' operator, the identifier type should follow the general rule
LHS = RHS
the lhs is long while the rhs is of type clock_t so explicitly tell the compiler to make in equal to double so the assignment is satisfied.
This type conversion is used in no of different places.
but mostly w.r.t pointers.
here is an example.
char *pChar; //pointer to charecter
int *pInt; //pointer to integer.
//assuming they are valid.
pInt = (int*)pChar; //type conversion.
another example is of malloc if you see the return type of malloc its void*. suppose you are allocating char buffer
you would write this way
char *pChar;
pChar = (char*)malloc(...); //LHS = RHS
hope i answered ur question.
This space is empty.
|
|
|
|
|
I'm a newbie, too, but this one seems straighforward enough...
Most timer functions report results in milliseconds, but this app wants a duration in seconds. It also wants the duration value to be a type double. After taking the difference of two clock_t values it divides by 1000 to convert the result to seconds, then the prefix (double) casts the clock_t result to a double type. Curiously, MSDN describes clock_t as a struct defined in TIME.H,
"clock_t structure Stores time values; used by clock. TIME.H"
but looking through TIME.H reveals,
#ifndef _CLOCK_T_DEFINED
typedef long clock_t;
#define _CLOCK_T_DEFINED
#endif /* _CLOCK_T_DEFINED */
I just love inconsistencies - they make learning this stuff so interesting.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
It's called a cast, and in this case it converts the integral result of (finish-start) to a double . This is important because without the cast, the division would be integer division, which would lose any remainder portion.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|
|
Now there's an interesting tidbit - the cast takes precedence over the division, eh? I learn something every time I visit here.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
me too, and also when mike talks.
This space is empty.
|
|
|
|
|
Excellent resource, our Michael is...
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
|
Yup yup... just found it in my Visual C++ 6 Core Language book. And it's not even in the fine print.
Will Build Nuclear Missile For Food - No Target Too Small
|
|
|
|
|
I get this linker error with
XXX error LNK2001: unresolved external symbol ___argc
XXX error LNK2001: unresolved external symbol ___argv
XXX error LNK2001: unresolved external symbol __mbctype
XXX error LNK2001: unresolved external symbol __mbctype
XXX error LNK2019: unresolved external symbol __mbctype referenced in function "protected: long __thiscall CEditView::OnFindReplaceCmd(unsigned int,long)" (?OnFindReplaceCmd@CEditView@@IAEJIJ@Z)
Do you guys know of any VC tools or command that could easily allows me to trace which portion of the codes are needing this function cause I am porting to VC 7 and the existing source codes are calling a lot of libraries which is in everywhere.
thanks in advance.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
I have just found the solution.
Just in case someone would be interested.
The solution is placing needed macro and header onto your header.
#define _AFXEXT //the magic define needed by MFC in order to enable afxext.h
#include <afxext.h>
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Could anybody answer this question? i'm not sure if i'm in the right place to post this... so if i'm not can someone kindly send me in the right direction please
Question:
**********
I am looking for some info on using a (small) program within a website,
the program takes some details and outputs a set of numbers, but i would like to encorperate this into a website through a form (that, in a way, mirrors the input parts of the program).
so when someone enters the info into the webpage form, it runs the info through the program and outputs the generated numbers back to the website.
Please help
Kind Regards,
GameBoy™ (aka - MobiTec) MobiTec.me.uk
**********************************
if ( noobie = "confused" )
{
print "Search Google© for answer";
} else {
print "Go buy a book and learn!";
}
|
|
|
|
|
sounds more like an asp question may be asp.net forum may help you.
GameBoy™ wrote:
if ( noobie = "confised" )
confised or confused?
This space is empty.
|
|
|
|
|
Well
if ( noobie = "confused" )
{
print "Search Google© for answer";
will always be true, and he will be searhing the google, else will never occur
|
|
|
|
|
How can I find out why my program is eating up 90%+ of the cpu on certian functions in a thread? The slowest functions do the following:
Parse out xml contents from an string (loop, CString::Mid) its like 7000 of these ... its not finding any corruption but its just really slow its in a thread and just is taking up a lot of the cpu.
Loops through all the items in a CArray structure (CStrings ctime, and one or two floats) and just does some stuff with teh float and scores of text.. but its takes like close to a minute
Are there any optimization techniques cause its taking like 3/4 minutes for the feature to complete its task and eats up a lot of resources on a 1.5ghz 128mb ram machine , not even wmp9 does that.
-Steven Hicks
CPACodeProjectAddict
|
|
|
|
|
How many threads? Sounds more like there is an infinite loop.
Kuphryn
|
|
|
|
|
Operations on float are costly.
This space is empty.
|
|
|
|
|
Yea the problem is I need percision to the 5 or 6 descimal place... what operator should I use?
-Steven Hicks
CPACodeProjectAddict
|
|
|
|