Okeydokey, long story short, i havent screwed around in C in QUITE a while. After i discovered the wonderful joys of the STL i never touched it again and thought it an evil archaic thing to deal with, however im faced with editing a small part of a program and im trying to move a single character from one place to another (the most trivial tasks seem the most complicated, dont they?)
A nice excerpt from the 1000+ lines of code in this file:
Code:
...
if (ch == EOF_CHAR) done(0);
/* Do Table Commands */
for (ccmd= cmd_char; ccmd->cmd != 0; ccmd++)
/*RATBAIT WAS HERE added ||...) TO ADD DEFAULT COMMAND STATE OF 1!*/
if (ch == ccmd->cmd || ccmd->cmd == 1)
{
/*RATBAIT WAS HERE added entire line TO NOT REMOVE PRESSED KEY AS PROMPT*/
if (ccmd->cmd == 1) { ccmd->prompt = ch; }
/* Check if command is enabled */
if (ccmd->enable == OPT_NONE || opt[ccmd->enable].yes)
{
/* Print the prompt */
STTY(0,&cooked);
putc(ccmd->prompt,stderr);
if (ccmd->cmd == 1) { /*MAGIC OCCOURS HERE*/ }
/* Read the command */
if (fgets(txbuf,BFSZ,stdin))
/* Execute the command */
(*ccmd->func)(txbuf);
else
{
/* Input aborted */
fputs(cancel,stderr);
clearerr(stdin);
}
STTY(0,&cbreak);
}
else if (ccmd->failmsg != NULL)
err(ccmd->failmsg);
else
speak(ch);
return;
}
...
Ok, there is a nice comment in there MAGIC OCCOURS HERE. Its the line above where we FGETS to read their input, and im trying to stick the character ch, or ccmd->prompt in FRONT of their input. Now its fine to stick it into stdin before their input, or concatinate their txbuf onto the end of it, or whatever. I just need a way to do this (note its 4am and i have been screwing around in console programming from pico for the last few hours over the world slowest modem to a terminal halfway across the country so my brain isnt working well, and i cant remember how to concatinate character to character * array thingy and i need aspirine) How do i concatinate to do what i want. (English shut off about an hour ago, plz bare with.)