Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Find a substring??

Author
Message
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 9th May 2008 21:44
How I search after a substring in a string? Like find "and" in the string "a, b and c."
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 9th May 2008 21:49
Probably the simplest way is with the C function strstr
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 02:29
Cheat, if you are having troubles still... I have something that might help... try the "standard ways first... then if you are still having a tough time, I have a home rolled string class that now has those sort of functions... Left, Mid, Right, IndexOf <--the one I'm thinking you'd need from your post). Also leverages the C++ libs for stuff like making all caps, all lowercase etc.

CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 10th May 2008 22:02
Thank you! But it don't print anything before dbInput. What is wrong?

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 10th May 2008 22:25


I'd suspect this at first glance. Specifically, you're treating this "text" pointer like a regular variable, it's not a separate copy.

Try making an empty char buffer as the final destination of the dbLower command




Something along those lines...

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 11th May 2008 09:29 Edited at: 11th May 2008 09:31
Quote: "int a = 0;
for(a = 0; a <= max; a++)"


A little bit of shorthand here. First of all you're assigning zero to 'a' twice. You could either leave the first argument out of your for loop

for ( ; a <= max; a++)

or just declare the one line as

(int a = 0; a <= max; a++)


and not declare it before the for loop. It has no bearing on your pogram but I hate to see CPU cycles go to waste.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 11th May 2008 21:10
But, nothing prints before the input anyway. I whant have the program like this:
"Hello!"
"Enter IP:"
Then you input something and puch enter to continue.

The code whith the changes:
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 11th May 2008 21:48 Edited at: 11th May 2008 22:00


That's not how it works. It's not an input box. It returns a buffer of characters typed at the keyboard. (ALL OF THEM) WHILE your program is running... each key you press that's not "special" like letters for example and cr(ascii13), tab, backspace etc.. are appended to this buffer.

You have to make your own routine that examines the buffer... handles reacting to backspace, tab, etc... and displaying the characters in your own maintained "InputString" ... After you read all the stuff in dbEntry() you should follow up with a dbClearEntryBuffer() call to "reset it".

If the pointer dbEntry returns == 0 then the buffer was empty.

That's why you're not seeing anything.

CheatCat
17
Years of Service
User Offline
Joined: 7th Mar 2007
Location: Sweden
Posted: 12th May 2008 21:03 Edited at: 12th May 2008 21:03
I don't understand... But I found another solution, but I cannot clean the screen, so it print the same text lot of times!

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 13th May 2008 02:30
You'll want to set the cursor mate... Put dbSetCursor(0, 0); somewhere at the top of your loop... That will fix your problem...

~~It's not who you are underneath, but what you do that defines you.~~

Login to post a reply

Server time is: 2024-09-29 19:26:38
Your offset time is: 2024-09-29 19:26:38