Getting Started

(lily) #1

Chapter 8: C Pointers and Arrays


Confuseusmoreandmoreandmore. Enough is too much. Let’s look at a practical



  1. The
    if it isn’t


ple from the AVR port of the Butterfly code. Real
oftware from real working programmers:

example:


int stringLength(char string)
{
for(int i = 0;
string != ‘\0’; string++) i++;
return i;
}


Calling stringLength(howdy) or stringLength(&howdy[0]) both return
stringLength function compares the character in the string with ‘\0’ and
that character then it increments the string pointer and the length count and loops.
Simple, easy and straightforward.


Let’s look at a practical exam
s

Free download pdf