 |
|
 |
|
Next: FS: Monster Bash Near Chicago
|
| Author |
Message |
External

Since: Mar 26, 2006 Posts: 9
|
(Msg. 1) Posted: Sun Mar 26, 2006 11:14 am
Post subject: Problems with PDcurses Archived from groups: rec>games>roguelike>development (more info?)
|
|
|
I'd like to preface this by saying that I am VERY new to the roguelike
development scene, so I'm trying to learn most of this as I go. I just
picked up a copy of PDcurses, and I've been experimenting with it.
addch() , addstr() and getch() seem to be working just fine, but I'm
having difficulties with getstr(). I run the code:
char *c = NULL;
getstr(c);
And as soon as I input any characters, the program quits with a fatal
error. Doesn't matter what I initialize c to, don't know what else to
change. The program compiles just fine, it just crashes whenever I try
to use getstr.
I'm using Microsoft VC++ 6.0, WinXP. Any other info you need?
Thanks in advance. >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
External

Since: Mar 26, 2005 Posts: 138
|
(Msg. 2) Posted: Sun Mar 26, 2006 5:55 pm
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
<kobuscrispi.DeleteThis@gmail.com> schrieb im Newsbeitrag
news:1143400453.038060.95490@u72g2000cwu.googlegroups.com...
> I'd like to preface this by saying that I am VERY new to the roguelike
> development scene, so I'm trying to learn most of this as I go. I just
> picked up a copy of PDcurses, and I've been experimenting with it.
> addch() , addstr() and getch() seem to be working just fine, but I'm
> having difficulties with getstr(). I run the code:
>
> char *c = NULL;
> getstr(c);
That not a PDCurses problem but a "C problem". You do not allocate memory
for the string. Try:
#define MAX_STRING_SIZE 100
char c[MAX_STRING_SIZE];
getstr(c);
HTH >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
External

Since: Mar 26, 2006 Posts: 9
|
(Msg. 3) Posted: Sun Mar 26, 2006 9:07 pm
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Mar 10, 2005 Posts: 97
|
(Msg. 4) Posted: Sun Mar 26, 2006 11:32 pm
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
copx wrote:
> <kobuscrispi DeleteThis @gmail.com> schrieb im Newsbeitrag
> > char *c = NULL;
> > getstr(c);
>
> That not a PDCurses problem but a "C problem". You do not allocate memory
> for the string. Try:
> #define MAX_STRING_SIZE 100
> char c[MAX_STRING_SIZE];
> getstr(c);
This has a fair chance of working but, in typical c string fashion,
getstr() could read MAX_STRING_SIZE or more characters and write past
the end of the array.
Can we constrained the getstr() function to a specified maximum length?
Lorenzo Gatti >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
External

Since: Mar 26, 2005 Posts: 138
|
(Msg. 5) Posted: Mon Mar 27, 2006 3:55 am
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
<gatti DeleteThis @dsdata.it> schrieb im Newsbeitrag
news:1143444735.107101.44980@j33g2000cwa.googlegroups.com...
>
> copx wrote:
>> <kobuscrispi DeleteThis @gmail.com> schrieb im Newsbeitrag
>
>> > char *c = NULL;
>> > getstr(c);
>>
>> That not a PDCurses problem but a "C problem". You do not allocate memory
>> for the string. Try:
>> #define MAX_STRING_SIZE 100
>> char c[MAX_STRING_SIZE];
>> getstr(c);
>
> This has a fair chance of working but, in typical c string fashion,
> getstr() could read MAX_STRING_SIZE or more characters and write past
> the end of the array.
> Can we constrained the getstr() function to a specified maximum length?
No. Use getnstr() if you want that. >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
External

Since: Mar 26, 2006 Posts: 9
|
(Msg. 6) Posted: Sun Apr 02, 2006 12:42 pm
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
All right, I've been getting a bit deeper into curses, and I now have
two questions:
1) The COLOR_PAIR(n) definitions only seem to allow for 8 colors
(black, blue, red green, cyan, magenta, yellow, white). How does one go
about getting more than just this very basic color set?
2) Looking through curses.h, I've found Key definitions for nearly
everything except for the escape key. Is there some windows default for
it that I'm unaware of, or what? >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
External

Since: Apr 02, 2006 Posts: 12
|
(Msg. 7) Posted: Sun Apr 02, 2006 7:55 pm
Post subject: Re: Problems with PDcurses [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
kobuscrispi DeleteThis @gmail.com wrote:
> 1) The COLOR_PAIR(n) definitions only seem to allow for 8 colors
> (black, blue, red green, cyan, magenta, yellow, white). How does one go
> about getting more than just this very basic color set?
Strictly speaking, there are 16 colors available: the light and dark
versions of each of those 8. Bright foreground colors are specified by
or'ing A_BOLD, bright background colors by A_BLINK (assuming that your
terminal isn't set to actually blink).
Beyond that, there's nothing, sorry. (init_color() would let you access
additional colors, if it worked, though still only 16 at a time.)
> 2) Looking through curses.h, I've found Key definitions for nearly
> everything except for the escape key. Is there some windows default for
> it that I'm unaware of, or what?
ESC is character 27 (0x1b), on all platforms that use ASCII, not just
Windows.
ESC is often avoided in curses-based programs, because -- on "real"
terminals -- it's sometimes used as the start of a multi-character
sequence. This is what the "notimeout()" function is about. But for
PDCurses, it doesn't apply. >> Stay informed about: Problems with PDcurses |
|
| Back to top |
|
 |  |
| Related Topics: | 7DRL: Invader - Well, I've talked myself into attempting a game for the 7DRL challenge. :-) Invader will be a sci-fi RL where the player is the planet's only hope of stopping a dread alien invasion ship. The character's base of operations will be their docked ship. ....
7DRL: TBA! :P - I'm going to throw my hat into the 7drl arena by taking on a project I've wanted to do for ages. I think it will get me past the mental block of actually getting started. My concept is based around the remains of a post apocalyptic world with gang..
7DRL : Commander - It is 13.40 in my time zone (GMT +100). Time to start my 7DRL project: Commander. I will do it in Free Pascal. Plans are quite big so there is real danger of failure. Good luck to all participants of 7DRL contest. -- Michal ''Ancient'' Bielinski
7DRL : Valley of Ge-Hinnom - Info : @ goes chase to Moloch, java, using my library, so if I fail at least I can post an updated library. T.
7DRL - Deserted... - Okay, Here's to learning new things :) I am beginning work on my 7DRL, Deserted. Everybody loves waking up on a desert island, right? C++, dev-cpp, minGW... no curses.. I'm just beginning to dip into that. So, everyone get ready for a monochromatic.. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|