Getting Started

(lily) #1

Chapter 8: C Pointers and Arrays


sendChar('l');

char greet[] = "Hello, world!\r*";

=0 ; greet[i] != '*'; i++)
{

y','\0'};
ate a char pointer


int to howdy[4]

sendChar('e');
sendChar('l');
sendChar('l');
sendChar('o');
sendChar(' ');
sendChar('w');
sendChar('o');
sendChar('r');
sendChar('d');
sendChar('!');
sendChar('\r');

SayHowdy();


Confuseus();


Confuseusmore();


}


void SayHowdy()
{


sendString("\rIn SayHowdy()\r");


for(int i


sendChar(greet[i]);
}
}


void Confuseus()
{
char howdy[] = {'h','o','w','d','
char *confuseus; // cre
char c; // create a char variable;
char c1, c2; // and a couple more


sendString("\rIn Confuseus()\r");


confuseus = &howdy[0]; // set confuseus to point to the howdy array;
confuseus += 4; // set it to po
c = confuseus; // set the contents of c to the contents of howdy[4]
sendString("c =
confuseus; = ");
sendChar(c);
sendChar('\r');


confuseus -= 4; // reset the pointer
c1 = *(confuseus + 1);

Free download pdf