954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with DevKitPro - Nintendo DS programming

I just started teaching myself some basic things with this, but the simplest shit like strings seems impossible. Does anyone know any good sources, tutorials, or anything that might help me more?

As an example...I wrote this code to tell when a control button was pressed:

//ProcessKeys
		int key;
		string s;
		s="";
		scanKeys();
		key = keysDown();
		if (key & KEY_DOWN){
			s="down";
		}
		if (key & KEY_UP){
			s="up";
		}
		if (key & KEY_LEFT){
			s="left";
		}
		if (key & KEY_RIGHT){
			s="right";
		}
		if (s!=""){
			iprintf(s);
		}


I get this error:

'string' was not declared in this scope


It doesn't know what string is?

Slyvr
Junior Poster in Training
74 posts since Dec 2010
Reputation Points: 10
Solved Threads: 3
 

Well, the first thing that comes to my mind, a PAlib project is still just basicly the heading of a header, it doesn't nullify your basic capabilities of the language, so, are you sure you remembered to #include "string.h" and using namespace std ?

KazenoZ
Junior Poster in Training
68 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
 

edit: I got it working, but only worked with #include instead of #include

One more compiling issue though with the final iprintf(s); statement

cannot convert 'std::string' to 'const char*' for argument '1' to 'int iprintf(const char*, ...)'


Is there a simple

s.toChar()


or something that I could use?

Slyvr
Junior Poster in Training
74 posts since Dec 2010
Reputation Points: 10
Solved Threads: 3
 

s.c_str() should do the trick =)

KazenoZ
Junior Poster in Training
68 posts since Jan 2011
Reputation Points: 10
Solved Threads: 2
 

Ah, yes, that fixed it. Thank you muchly

Slyvr
Junior Poster in Training
74 posts since Dec 2010
Reputation Points: 10
Solved Threads: 3
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You