[chbot] C prinf() %s

hamster hamster at snap.net.nz
Tue Nov 22 03:21:39 GMT 2011


Doh! What an oversight - it might have gibberish following the new line.
eg "Hello\nWorld\n" should only print "Hello".

If you are doing a quick and dirty, try...

while(*str != '\n')
{
   putchar(*str)
   str++;
}

Or if you aren't sharing the data
  int i=0;
  while(str[i] != '\n')
    i++;
  str[i] = '\0';
  printf("%s",str);
  str[i] = '\n';


On Tue, 22 Nov 2011 16:10:21 +1300, Mark Atherton <markaren1 at xtra.co.nz>
wrote:
> Or.. copy the array to a temp array, then scan the temp array and 
> overwrite the \n with \0 ?




More information about the Chchrobotics mailing list