|
-
Nov 29th, 2001, 07:04 PM
#1
Thread Starter
Frenzied Member
not displaying 1 character
Code:
for(i=1; i<=sizeof(big); i++) {
if(big[0] == '*') {
StartCopy == true;
//MessageBox(ghWnd_Main, "COPY = TRUE!", "Copy Test", MB_OK);
}
else if(StartCopy == true) {
linkURL[holder] = big[i];
holder++;
}
//MessageBox(ghWnd_Main, linkURL, "linkURL", MB_OK);
}
MessageBox(ghWnd_Main, big[1], "big", MB_OK);
SearchMode=3;
heres a block of my code...why does the messagebox displaying big[1] show a whole string starting from 1???? I only want to use that character
Last edited by SteveCRM; Nov 29th, 2001 at 07:07 PM.
-
Nov 29th, 2001, 07:29 PM
#2
transcendental analytic
a char is not a c style string, a c style string is a character array that is null terminated. Copy the char into a string buffer of 2 chars with second char=0
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 29th, 2001, 09:00 PM
#3
Thread Starter
Frenzied Member
didn't know that...thanks ked I'll give that a go!
-
Nov 29th, 2001, 09:12 PM
#4
Thread Starter
Frenzied Member
having some trouble, could anyone stear me in the right direction?
Code:
char test;
bool StartCopy = false;
int holder = 1;
for i=1; i<=sizeof(big); i++) {
test = big[1];
if(test == '*') {
StartCopy == true;
MessageBox(ghWnd_Main, "COPY = TRUE!", "Copy Test", MB_OK);
}
else if(StartCopy == true) {
linkURL[holder] = big[i];
holder++;
}
//MessageBox(ghWnd_Main, linkURL, "linkURL", MB_OK);
}
//MessageBox(ghWnd_Main, &test, "test", MB_OK);
I can't get it to check if the first character is a *...I want the "Copy Test" messagebox to pop up.
-
Nov 29th, 2001, 09:22 PM
#5
Frenzied Member
Arrays are indexed starting from 0. So the first letter is big[0].
Harry.
"From one thing, know ten thousand things."
-
Nov 29th, 2001, 10:10 PM
#6
Thread Starter
Frenzied Member
doesn't get the messagebox to show up (i know there is a * in the string...but im checking with the loop to see if its the character Im on)
-
Nov 30th, 2001, 01:04 AM
#7
PowerPoster
Try declaring the test char as:
-
Nov 30th, 2001, 07:57 AM
#8
Frenzied Member
Code:
char test;
bool StartCopy = false;
int holder = 1;
for i=1; i<=sizeof(big); i++) {
test = big[1]; // point A
if(test == '*') {
StartCopy == true;
MessageBox(ghWnd_Main, "COPY = TRUE!", "Copy Test", MB_OK);
}
else if(StartCopy == true) {
linkURL[holder] = big[i];
holder++;
}
//MessageBox(ghWnd_Main, linkURL, "linkURL", MB_OK);
}
//MessageBox(ghWnd_Main, &test, "test", MB_OK);
Look at the bit of the code I have commented with 'point A'. You are assigning big[1] to the variable 'test' every time in the loop. big[1] is the second letter in the string, so you will always be checking the second letter. If you were intending to check every letter with that loop you should check big[ i ], or if you want to check the first letter, you should check big[0].
Try this:
Code:
char test;
bool StartCopy = false;
int holder = 1;
for i=1; i<=sizeof(big); i++) {
test = big[ i ]; // point A - changed to big[ i ]
if(test == '*') {
StartCopy == true;
MessageBox(ghWnd_Main, "COPY = TRUE!", "Copy Test", MB_OK);
}
else if(StartCopy == true) {
linkURL[holder] = big[i];
holder++;
}
//MessageBox(ghWnd_Main, linkURL, "linkURL", MB_OK);
}
//MessageBox(ghWnd_Main, &test, "test", MB_OK);
Harry.
"From one thing, know ten thousand things."
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
|