0

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?

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by Slyvr
0

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 ?

0

edit: I got it working, but only worked with #include <string> instead of #include <string.h>

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?

Edited by Slyvr: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.