|
You question is not very clear to me.
I'm assuming you're having trouble when stepping into the MFC code.
You can use the following shortcut keys while debugging -
F10 will step over the function.
F11 will step into the function.
Shift + F11 will step out of the function.
Here is a link to the complete list of debugging shortcut keys -
Debugger Shortcut Keys[^]
|
|
|
|
|
when I step thru it
it just goes off somewhere
meaning the yellow arrow disappears and my main window is displayed
seems like it bypassed executing some code
|
|
|
|
|
i am receving data from serial port and i have to display in two dialog boxes,but the data is not being received in second dialog.The first dialog is parent of second dialog.I am using MSComm ActiveX controls. i am closing the port and opening again.
Please help me to solve the problem.
Thanks in advance
|
|
|
|
|
There is probably no data available to read.
The serial port by default acts like a pipe.
Data is removed from the port after it is read.
So the parent dialog is probably reading all the data leaving nothing available for the child dialog.
Also, please do all error checking and see if any of the calls are failing.
|
|
|
|
|
If I were you, I would write a wrapper around your serial port (and most probably get rid of MSComm active X). This class would then store the data so that mutliple parts of your application can retrieve the required information.
|
|
|
|
|
#include <iostream.h>
int main()
{
int x=1,y;
y= ++x*++x;
cout << x << endl;
cout << y <<endl;
return 0;
}
|
|
|
|
|
Because you shouldn't use the pre-increment operator that way.
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
[My articles]
|
|
|
|
|
Hello
It's not very hard. answer of this simple question is :
YOU WRITE ++x TWICE.y=++x[first time]*++x[second time]
don't forget to vote me.
BYE...
|
|
|
|
|
++x
*
++x
You should not use expressions like this as they may not give the results you expect.
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: You should not use expressions like this as they may not give the results you expect.
I welcome you to take a look at our codebase.
Workout progress:
Current arm size: 14.4in
Desired arm size: 18in
Next Target: 15.4in by Dec 2010
Current training method: HIT
|
|
|
|
|
Note that priority of ++ operation is higher than *.If you have y= ++x*x++ it should be 4.
I would recommend you not to use such features because it makes code very hard to understand and modify.
Keep it simple and you will avoid getting in troubles.
Life is a stage and we are all actors!
|
|
|
|
|
Hristo Bojilov wrote: Keep it simple
I agree.
BTW: the exact order of the expression evaluation and the side-effects has been undefined in many languages for a long time. However IMO a compiler should issue a warning whenever you rely on assumptions, i.e. undefined results.
|
|
|
|
|
|
Hello all
this is my maze. when the worm reach to wall it passes the wall and sometime it stops.
#include <stdio.h>
#include <conio.h>
int dir=0;
char wall[40][50]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1},
{1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1},
{1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,1,1,1,1,1,1,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
create_wall();
arrow_keys();
void main()
{
int a=3,b=2;
create_wall();
lbl : arrow_keys();
if (dir==72){
b-=1;
if (wall[a][b]==0){wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
else b+=1;goto lbl;
}
if (dir==75){
a-=1;
if (wall[a][b]==0){wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
else a+=1;goto lbl;
}
if (dir==77){
a+=1;
if (wall[a][b]==0){wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
else a-=1;goto lbl;
}
if (dir==80){
b+=1;
if (wall[a][b]==0){wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
else b-=1;goto lbl;
}
if (dir==0) {printf("exit");}
}
create_wall(){
clrscr();
int i,j;
for(i=0;i<15;i++){
for(j=0;j<26;j++){
if (wall[i][j]==1) printf("²");
else printf(" ");
}
printf("\n");
}
gotoxy(2,2);
printf("**");
}
int arrow_keys()
{
int ch;
while(1)
{
ch=getch();
if(ch==0)
{
ch=getch();
if(ch==72) {dir=72; break;}
if(ch==75) {dir=75; break;}
if(ch==77) {dir=77; break;}
if(ch==80) {dir=80; break;}
}
else dir=0;
break;
}
}
Where is the problem.
|
|
|
|
|
Here are a few ideas for you to make life easier in the future:
1. Don't use global variables when you don't have to. In your case, wall might be acceptable, but dir should not be global.
2. Don't confuse others by writing wall[40][50] and only initialize 15/26.
3. If wall is global, add globals for the wall bounds as well. You don't want to use hard coded values (like 15 and 26) anywhere else but very close to you wall definition. (you can't trust sizeof() operator either the way you have done it)
4. Be consistent in your naming. Don't use indexes a and b in one place, and i and j in another for the same thing. x and y would do just fine.
5. Do not use labels and goto where a simple loop will be enough. Your code will be hard to follow and maintain, even if it's correct. If you need a label, and it will be a long time before you do, give it a meaningful name.
6. Let arrow_keys return its value instead of changing a global variable. It's defined to return an int, but never does. So is also create_wall() by the way.
7. Use constant identifiers instead of hard coded numbers. An enum type is well suited for your direction variable. Again, think of naming.
8. printf("%c", ...)? Have a look at putc().
9. Indentation looks a bit random, and so does placement of curly brackets. Adopt a consistent style.
That said, finding these kinds of bugs is an easy job if you step through the code in a debugger, inspecting indexes into your wall matrix.
But clean up your code first.
|
|
|
|
|
Hello all
I am working on maze in turbo c(command prompt not windows). I write 90% of it.
but there are 2 problems I do any work can't solve it.
1- When worm(** is my worm) reach a wall it don't stop. it can pass the wall?
2- the worm make longer but it should be ** in any time?
#include <stdio.h>
#include <conio.h>
int dir=0;
char wall[40][50]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,1,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1},
{1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1},
{1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,1,1,1,1,1,1,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1},
{1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,0,1},
{1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
};
create_wall();
arrow_keys();
void main()
{
int a=3,b=2;
create_wall();
lbl : arrow_keys();
if (dir==72){b-=1; wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
if (dir==75){a-=1; wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
if (dir==77){a+=1; wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
if (dir==80){b+=1; wall[a][b]='*';gotoxy(a,b); printf("%c",wall[a][b]);goto lbl;}
if (dir==0) {printf("exit");}
}
create_wall(){
clrscr();
int i,j;
for(i=0;i<15;i++){
for(j=0;j<26;j++){
if (wall[i][j]==1) printf("²");
else printf(" ");
}
printf("\n");
}
gotoxy(2,2);
printf("**");
}
int arrow_keys()
{
int ch;
while(1)
{
ch=getch();
if(ch==0)
{
ch=getch();
if(ch==72) {dir=72; break;}
if(ch==75) {dir=75; break;}
if(ch==77) {dir=77; break;}
if(ch==80) {dir=80; break;}
}
else dir=0;
break;
}
}
Please help me to solve the problems.
Thanks in advance
|
|
|
|
|
|
You're not erasing where the "worm" is when you draw the new one on the screen and you're not testing where the new worm head is and ending the game (if that's the rule) when the worms head hits a wall. To get round these problems:
- You can deal with the extra drawing by overwriting the worm's current position with spaces after you poll the keyboard but before you change the position of the worm.
- When you change the worm's position do a check to see if the new position overwrites a 1 in your maze. If it does, end the game.
Cheers,
Ash
|
|
|
|
|
Hello Ash;
I wrote these codes you say me. but it doesn't work correctly. It stop in another position that there is no wall and sometime it pass a wall and stop on the next one.
These code are right, but I can't write them in its own place.
Please help me by writing codes if it is possible for you.
|
|
|
|
|
I'm trying to write a bho to get the ocx in IE. I'm a newer to bho. I'm not famailar with com. I really need your help. Please, help me, and I will really appreciate your help!
|
|
|
|
|
Already posted in COM forum.
It's time for a new signature.
|
|
|
|
|
Hi,
i'm using WMI to get some Parameters of the local Computer.
Here is a Sample Code Snippet:
<code>
pEnumerator = NULL;
hres = pSvc
->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_BIOS"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
*pclsObj;
uReturn = 0;
while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1,
&pclsObj, &uReturn);
if(0 == uReturn)
{
break;
}
VARIANT vtprop;
hr = pclsObj->Get(L"SerialNumber", 0, &vtprop, 0, 0);
wcout << vtprop.bstrVal << endl;
VariantClear(&vtprop);
pclsObj->Release();
}
</code>
This works very well.
How must i change this, to show the IP-Adressses of the Computer? Only with Changing to "Win32_NetworkAdapterConfiguration" and "IPAddress" instead of "SerialNumber" doesn't works.
I think, because IPAdress is an Array in WMI?
modified on Saturday, June 19, 2010 12:50 PM
|
|
|
|
|
Go over to Microsoft and download: WMI CIM Studio. With it you can search the entire WMI on your local machine.
But, and I'm trying to remember, I think the IP address is written to the Registry when you connect to a Wireless network. I'd have to look it up. Get back tp you.
|
|
|
|
|
Sorry but this is not the solution for my Problem. I need help with my C++-Code above. That's why i have asked in this forum and not anywhere else
|
|
|
|
|
|