-
July 1st, 2008, 08:35 PM
#1
CString array question
here is the code i need to ask about.
in header file:
CString Amsg[18];
CString Bmsg[18];
BOOL appeartwice;
BOOL press;
int switch;
int LED;
int i;
in the cpp file:
Amsg[0]="Hello";
Bmsg[0]="Hello";
......
......
Amsg[17]="GoodBye"
Bmsg[17]="GoodBye"
for(i=0; i<18; i++)
{
if(Amsg[i]==Bmsg[i])
{
appeartwice= TRUE;
}
}
if(switch == 1) //Button pressed
{
press=TRUE;
}
if((appeartwice==TRUE)&&(press==TRUE))
{
LED=1; //LED turn on.
}
else if(((appeartwice==FALSE)&&(press==TRUE))||((appeartwice==TRUE)&&(press==FALSE)))
{
LED=0; //LED turn off
}
now the question i want to ask is if this if(Amsg[i]==Bmsg[i]) condition valid for Visual C++ to read it?
or is the way to compare CString array with Cstring array is different?
i build my whole program with no errors detected but when i run it i have error window popped out.
-
July 1st, 2008, 08:40 PM
#2
Re: CString array question
What happens if you put a break point on the line:
What do the array strings look like in the watch window?
-
July 1st, 2008, 09:11 PM
#3
Re: CString array question
Your if statment is valid. CStrings have the == operator defined for comparisons. Surely your debugger can provide some information about the error, or at a minimum there is some kind of message in the "error window".
-
July 1st, 2008, 11:36 PM
#4
Re: CString array question
Originally Posted by Arjay
What happens if you put a break point on the line:
What do the array strings look like in the watch window?
i cant use the watch window as i cant select or add variables into the watch window.
-
July 1st, 2008, 11:59 PM
#5
Re: CString array question
Originally Posted by ashwarrior
i cant use the watch window as i cant select or add variables into the watch window.
What version of Visual Studio are you using?
-
July 2nd, 2008, 01:29 AM
#6
Re: CString array question
-
July 2nd, 2008, 10:26 AM
#7
Re: CString array question
Upgrade your compiler to 2008 or at least 2005 and try again.
So many improvements have been made to the IDE since the 10 year old VC6 came out.
For example, the watch Window. Nowadays, you can drag your variable in the watch window on-the-fly and see the values.
You can even hover over the variable in the source code while debugging and see the value.
You can see UNICODE strings without having to type ',su' after the string.
These are just 3 improvements that I can think of and there are 100's more.
-
July 2nd, 2008, 10:55 AM
#8
Re: CString array question
Originally Posted by ashwarrior
visual c++ 6.0
Originally Posted by ashwarrior
i cant use the watch window as i cant select or add variables into the watch window.
I never had such a problem in vc++6.0. Neither with Debug window nor with a watch one.
ashwarrior, you are surely doing something wrong or not completely.
Victor Nijegorodov
-
July 2nd, 2008, 11:11 AM
#9
Re: CString array question
Watch windows work in VC6, but that isn't really important. The program seems to be crashing. The debugger should be able to tell him something useful with or without watch windows.
-
July 2nd, 2008, 08:09 PM
#10
Re: CString array question
Originally Posted by Arjay
Upgrade your compiler to 2008 or at least 2005 and try again.
So many improvements have been made to the IDE since the 10 year old VC6 came out.
For example, the watch Window. Nowadays, you can drag your variable in the watch window on-the-fly and see the values.
You can even hover over the variable in the source code while debugging and see the value.
You can see UNICODE strings without having to type ',su' after the string.
These are just 3 improvements that I can think of and there are 100's more.
Where i download the latest compiler?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|