String help?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: String help?

Post by ibly31 »

MarauderIIC wrote: And it's not STD::string. It's std::string.
I was typing it on my iPod Touch, and it thinks i was talking about Sexually Transmitted Diseases, and obviously I would have figured it out, the compiler might have even fixed it as i was typing it :D
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: String help?

Post by MarauderIIC »

Haha, alright.

Also, I've used the console with SDL applications (on accident). My checkers program actually took cin and cout and updated the separate SDL window (it was originally a console app and I just changed main() to have argc and argv and built it with SDL).
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
programmerinprogress
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 632
Joined: Wed Oct 29, 2008 7:31 am
Current Project: some crazy stuff, i'll tell soon :-)
Favorite Gaming Platforms: PC
Programming Language of Choice: C++!
Location: The UK
Contact:

Re: String help?

Post by programmerinprogress »

Really? well I can't get it to work, and i've done some googling, and apparently this problem is quite common, and i've tried the majority of the remedies suggested (with the exception of the ones that want me to recompile SDL), most of them state that SDL 'redirects' streams to output files.
---------------------------------------------------------------------------------------
I think I can program pretty well, it's my compiler that needs convincing!
---------------------------------------------------------------------------------------
And now a joke to lighten to mood :D

I wander what programming language anakin skywalker used to program C3-PO's AI back on tatooine? my guess is Jawa :P
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: String help?

Post by ibly31 »

I packaged a nice little function, its called addInt(std::string, int num)

and you'd call it by this

std::string asfd = addInt("Value = ",value);

draw asdf...
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
Scoody
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Fri Feb 06, 2009 2:07 pm

Re: String help?

Post by Scoody »

ibly31 wrote:I don't wanna make a whole new string and a new header... Then there'd be the problem of concertng that back to a STD::string and them to a c_str()
Actually, mystringstream.str() is the converted string-version and mystringstream.str().c_str() for the C-string. But since that's not what you wanted to do I won't delve deeper.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: String help?

Post by ibly31 »

Yeah, lol i ended up using stringstream anyway.

I have a question on Keystates, they arent working... whats wrong with this code?

Code: Select all

		Uint8 *keystates = SDL_GetKeyState(NULL);
		
		if(keystates[SDLK_UP])
			charY -= speedX;
		
		if(keystates[SDLK_DOWN])
			charY += speedY;
		
		if(keystates[SDLK_LEFT])
			charX -= speedX;
		
		if(keystates[SDLK_RIGHT])
			charX += speedX;
			  
		if(keystates[SDLK_ESCAPE])
			quit = true;
			  
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: String help?

Post by Ginto8 »

It looks fine... Could you tell us what's happening wrong?
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: String help?

Post by ibly31 »

I fixed it, the main while(quit == false) loop didn't have another while(pollevent) loop inside it.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
Post Reply