/*** putting on flame suit ***/
You obviously don't understand correctly... re-read his question.
Would this satisy the requirements if all he has to do is print the string?
void
without_a_hammer(char *s)
{
if(s && *s) {
char *p = s +1;
while(*p)
putchar(*p++);
printf("%ca\n", *s);
}
return;
}
Or without using wood. It is a fundamental property of C's string that
they reside in arrays.
/*** zipping up flame suit ***/
Who cares what they reside in, he asked how to manipulate the string!
As long as the caller ensured that the 'array' the string 'resides' in can
accommodate an extra byte... what's wrong with this?
void
without_using_wood(char *s)
{
if(s && *s) {
char *p = s +1;
int ch = *s;
while(*p)
*s++ = *p++;
sprintf(s, "%ca", ch);
}
return;
}
/*** starting the fire ***/
OP: here's a driver to test the first example... it will print out the
strings passed on the command line!
void
main(int oh, char *boy[])
{
while(*++boy)
without_a_hammer(*boy);
return; /* NOTHING!!!! HAHAHAHA */
}
/*** giggling with anticipation as I wait for it to burn
***/
Regards,
Mark