From: "Ingo Ruhnke" Newsgroups: comp.os.msdos.djgpp Subject: Re: Strings in Allegro Date: 24 Nov 1997 20:47:52 GMT Organization: Telemedia News Server Lines: 54 Message-ID: <01bcf8ec$83ef4e40$0200a8c0@ingo> References: <34736E60 DOT DAA8E2D5 AT primenet DOT com> NNTP-Posting-Host: gtso-m71-244.pool.mediaways.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Mike McLean schrieb im Beitrag <34736E60 DOT DAA8E2D5 AT primenet DOT com>... > I'm writing a game in C++ & allegro, and I would like to input text > strings like "hello", and have it appear on screen, then this code could > be checked by an if loop and run whatever function is intended to be > run. I set up a test using cin. I read in a char of 10, and output it > using textprintf. It printed the text out fine, but it didn't print the > word becuase it's a text function running in graphics mode. I got a > bunch of junk at the top of the screen. I understand this, but I want > to know if there is a similar function to cin in allegro. > > Any help/info is greatly appreciated Look at the example programm from allegro (ex14.c) it demonstrate how to use the GUI-Routines from Allegro to do that, or programm an input routine yourself like this: /**************** begin ****************/ #include void getline(char *buf, int x, int y, int color) { char c; int i; for(i = 0; (c = readkey() & 0xff) != '\n' && c != '\r'; ++i) { buf[i] = c; buf[i+1] = '_'; buf[i+2] = '\0'; textout(screen, font, buf, x, y, color); } buf[i] = '\0'; } int main() { char buf[100]; allegro_init(); install_keyboard(); install_timer(); set_gfx_mode(GFX_VGA, 320, 200, 0, 0); getline(buf, 100, 20, 15); allegro_exit(); } /**************** end ****************/ It works, but it may need some improvements. Ingo