   SDL and handling input for string
  Im in the middle of making a game, but one of the things about the games is that im going to need to be able to get input take the input and put it to a string if necessary. Right now i got some code written but it doesn't work and it's giving me a head ache. It uses SDL, Cone3d's Font, and a array of keys.  #ifndef readKB_cpp#define readKB_cpp#include <SDL\SDL.h>#include <string.h>char *makeString(bool key[256], char *str) {    char *con;    for(int i=0; i<256; ++i) {   //See if it's a letter   if(key[i]) {  //lower case  if(  (i >= 97) && (i <= 127)  ) { con[0]=char(i); strcat(str, con); return str;  }  // Upper case  if(  (i >= 65) && (i <= 90)  ) { con[0]=char(i); strcat(str, con); return str;  }  //?  if( i == 63 ) { con[0]=char(i); strcat(str, con); return str;  }  //.  if( i == SDLK_PERIOD ) { con[0]=char(i); strcat(str, con); return str;  }  //?  if( i == SDLK_DOLLAR ) { con[0]=char(i); strcat(str, con); return str;  }  //Remove Character  if( i == SDLK_BACKSPACE ) { str[ (strlen(str)-1) ]=NULL; return str;  }  //Return  if( i == SDLK_RETURN ) { strcat(str, "\n"); return str;  }   } }    return str;}   #endifwhat happens is that when i press a key that is interpretted by the function, the program quits. if anyone has any reason why it happens or how to fix it i would greatly appreciate it.[edited by - hogosha on February 15, 2004 8:32:14 PM]
  It looks like you''re not allocating any memory for your char *con.  I''m not really sure why you made that a pointer anyway.  I would just change it to a regular char.  Then assign a letter to it like this:  con = char(i);;  use the unicode translation from SDL, its exactly what you want. ;  if you have a suggestion on how i should go about this or an example it would be appreciated. i''ve been trying several different ways of doing it and everything hasn''t worked. ;  how do i use the unicode? ;  thx for the unicode tip. I got it to work now, and working quite nicely, i appreciate it. void makeString(SDL_Event &event, char str[]) {    str[strlen(str)]=event.key.keysym.unicode & 0x7F;}final product. i hope someone else can use it as well. 