I
irwishlaw
In Chapter 2 of the book 'C Unleashed' the author states that this
code
#include <stdio.h
void increment(char *p)
{
++p
}
int main(void)
{
char *s = "Hello world";
increment(s);
printf("%s\n", s);
return 0;
}
"doesn't work (and in fact results in undefined behavior):"
Modified code that does work, that is, code that prints "ello world"
is not shown.
What is is proper way to modify the code so that "ello world" is
printed?
Robert Wishlaw
code
#include <stdio.h
void increment(char *p)
{
++p
}
int main(void)
{
char *s = "Hello world";
increment(s);
printf("%s\n", s);
return 0;
}
"doesn't work (and in fact results in undefined behavior):"
Modified code that does work, that is, code that prints "ello world"
is not shown.
What is is proper way to modify the code so that "ello world" is
printed?
Robert Wishlaw