Chapter 8: C Pointers and Arrays
inter
rrays, but they
e mu grammers (and those of us with
pidly an issue in microcontrollers, and
inter rn how pointers and arrays relate and apply it in
n faster. Let’s look at some examples.
.
y[6];
ts as s bytes sized memory locations, since each
e‘ve
howdy[0] = ‘h’;
;
;
e the array:
,’\0’};
char greet[] = "Hello, world!\r*";
for(int i =0 ; greet[i] != '*'; i++)
{
sendchar(greet[i]);
}
}
Po s and arrays have a strong relation in C. Any array-subscripting operation
can also be done with pointers. Pointers are said to be faster than a
ar ch harder to understand for novice pro
ra diminishing brain cells). Since speed is
po s are faster we need to lea
code segments that must be made to ru
char owdy[6]; h
Sets aside an array of six contiguous byte-sized memory locations
int howd
Se ide an array of twelve contiguou
int requires two bytes of memory.
W seen before how to assign data:
howdy[1] = ‘o’
howdy[2] = ‘w’
howdy[3] = ‘d’;
howdy[4] = ‘y’;
howdy[5] = ‘\0’;
or we can do this when we defin
char howdy[] = {‘h’,’o’,’w’,’d’,’y’
Here’s a puzzle for you:
char *confuseus;
char c;