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 / strings and if statements

Author
Message
flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 16th Jul 2008 17:13
Hey, just got Dark GDK yesterday, and im already completely confused
Working on a little variable program right now. I got numbers down, so i moved onto strings. My program gets a user input, and then what i WANT it do is

if string = "fart" then print "how foul"

I know thats not DGK at all, but it gets my point accross
here is my source.



When I go to compile it, it runs fine. But, even if the user input is fart, it doesnt say "how foul"

Thanks in advance


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 16th Jul 2008 17:25
hello and "fart" are both addresses to strings, what you're doing there is comparing their addresses only, if you want to compare the strings that the pointers point to, then you'd want to use 'if ( !strcmp( hello, "fart" ) )', you'll need string.h for this.

flashing snall
19
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Boston
Posted: 16th Jul 2008 17:33 Edited at: 16th Jul 2008 17:37
Hmm. Okay, that makes sense I guess. But when I tried to put that instead of my current if statement, it wouldnt compile. Ill try and figure it out, but help is ALWAYS welcome.

Thanks for the help already.

EDIT:
ah HA!
it has been accomplished

I think i was just missing the }
thank you very much good sir.


This is my WIP, not even ready for a WIP thread yet though.http://smallgroupproductions.com/

Login to post a reply

Server time is: 2024-11-20 17:47:24
Your offset time is: 2024-11-20 17:47:24