Original Post
hi all, the answer to the question im about to ask will probably be a little obvious to most of you, its got something todo with chars :s
i was brought up using borland c++ builder (:s i know) which had a very easy way of managing strings (kinda like stl) so i never had much experience with chars because bcb's inbuilt string did everything i needed. now im using vc++ and dont have the option of using these strings, not due to availability, i could use stl - but because the code i have to write is focused on speed this isnt viable, so ive gotta use raw char *.
ive experimented with them and to a certain extent acheived what i set out to do. however
i have come seriously unstuck on a problem that i can see no way of solving - its post on gamedev time!
right... basically im writing a console frontend for a game engine im writing. ive got the input, storage and the like all coded. i store commands recieved in a buffer which is executed every frame and the output is spat out to the console. the command buffer and console text are both stored using linked lists of classes that represent one line of text:
//---------------------------------------------------------------
class CCommandBufferLine{
public:
//-------------------------------------
CCommandBufferLine(char *ps_text){
}
//-------------------------------------
~CCommandBufferLine(){
if(p_next) p_next->p_prev = p_prev;
if(p_prev) p_prev->p_next = p_next;
p_next = p_prev = NULL;
}
//-------------------------------------
CCommandBufferLine *p_next;
CCommandBufferLine *p_prev;
//-------------------------------------
char s_text[con_MAX_INPUT_LINE_SIZE];
//-------------------------------------
};
//---------------------------------------------------------------
the class that stores the text for the console is similar. now my problem is actually how to get the text stored in the passed character string into s_text. i dont have a clue, ive tried everything i can think of, its definatly summut todo with pointers, as before classes of this type are instantiated, that char *ps_text thats passed in is passed around a few functions before it gets passed to the creation of the console line / buffer. heres a brief overview:
RecieveInput(){
AppendToBuffer(s_input_line);
}
AppendToBuffer(char *ps_text){
CCommandBufferLine *p_temp_command_line = new CCommandBufferLine(ps_text);
}
by the way s_input_line is defined as
char s_input_line[con_MAX_INPUT_LINE_SIZE];
i was wondering if anyone can see what im doin wrong - i traced through the program and it seems that it all goes a bit pete tong when i try and pass the string to other functions :<
if anyone can shed some light on this st00pid problem id be a very very happy person :D
thanks, Fusi0n^
"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle
[edited by - Fusi0n on December 24, 2002 7:40:27 PM]
