Chapter 8: C Pointers and Arrays
d!’ as follows:
);
);
itializ
ns the array sending chars until it finds the ‘*’
void func2(char *yalo)
{
yalo++; // the variable at address yalo is incremented
}
This time func2 increments olay in func1 and olay becomes ‘n’ in both.
Arrays
Arrays are groups of consecutive objects. We could write a code fragment for
responding to a ‘?’ by sending each character of ‘Hello Worl
if (val=='?')
{
sendchar('H');
sendchar('e');
sendchar('l');
sendchar('l');
sendchar('o'
sendchar(' '
sendchar('w');
sendchar('o');
sendchar('r');
sendchar('l');
sendchar('d');
sendchar('!');
sendchar('\r');
}
Looks like a group of consecutive objects to me. Formally, we would define and
in e an array for this in C as:
char greet[] = "Hello, world!\r*";
And write a function that sca
void SayHowdy()
{