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 / Input help

Author
Message
m2zt
19
Years of Service
User Offline
Joined: 12th Nov 2005
Location:
Posted: 28th Oct 2006 04:47
I am trying to understand strings and characters in C++ but im not getting anywhere when using dbInput();



When i input m2zt and compare it with mmm it doesnt work. So i tried having answer = "m2zt" and compare it and it does work. So I am a bit confused on what to do with dbInput.

Futurama 2008
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 28th Oct 2006 18:35
I'm not sure if you can store a string into a pointer to a char (but point to its address). And definitively I'd use C string functions to compare them, rather than '='.

Please check this working one, based on yours:

m2zt
19
Years of Service
User Offline
Joined: 12th Nov 2005
Location:
Posted: 28th Oct 2006 23:34
Thanks, that helps alot.

Futurama 2008
Miguel Melo
19
Years of Service
User Offline
Joined: 8th Aug 2005
Location:
Posted: 29th Oct 2006 00:56
Morcilla, you can have


That just statically allocates the string and makes mmm point to it. The problem with his code was just with the "==" as you pointed out.

That would only yield true if both pointers pointed to the very same address in memory. It will return false if both pointers point to diff mem places even if they both contain the same sequence of characters.

I have vague plans for World Domination
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 29th Oct 2006 11:09
Miguel, that makes sense, good to know.

Login to post a reply

Server time is: 2024-11-19 09:40:17
Your offset time is: 2024-11-19 09:40:17