21 lines
666 B
C
21 lines
666 B
C
|
#include <stdio.h>
|
||
|
void print_all(char* word, int len) {
|
||
|
// TODO: print all characters in the array you were given in this function
|
||
|
// don't use the [] operator, do your own calculations on the address
|
||
|
}
|
||
|
|
||
|
int main(int argc, const char *argv[])
|
||
|
{
|
||
|
// We can rely on pointer arithmetic to access values in the array,
|
||
|
// since an arrays values are stored in consecutive memory cells.
|
||
|
char word[] = {'H', 'e', 'l', 'l', 'o'};
|
||
|
|
||
|
// Get the arrays second character
|
||
|
// we add the offset 1 to get the second index
|
||
|
char second = *(word + 1);
|
||
|
// We print the arrays second character
|
||
|
printf("%c\n", second);
|
||
|
|
||
|
print_all(word, 5);
|
||
|
}
|