Notes for class

 

Void strcopy(char *d, *s)

{

                  while(*d++ = *s++);

}

 

void strcopy(char *d, *s)

{

while(*s!=0)

{

                  *d = *s;

                  d = d + 1;

                  s = s + 1;

}

*d = 0;

}

 

Both of these segments of code do exactly the same thing.

 

__________________

 

Problem: a divide by four gives a 1 or 2 remainder

Solution:

 

If((a%4) == 1 || (a%4) == 2){..

 

Oreven better would be.

 

If((a+1)&2){

 

Explanation:

0 00    +1        ->             01

1 01     +1        ->             10    -use & to check for true with 10

2 10    +1        ->             11    -use & to check for true with 10

3 11    +1        ->             00

 

_______________________________

 

 

 

 

 

 

 

 

 

void JC(char *d, *s)

{

                  while(*s)

                  {              

                                    if(*s == _)

                                                      *d = _;

                                    else

                                                      *d = A + ((*s A) +7) %26);

                  }

                  d++;

                  s++;

                  *d=0   -> this sets the NULL

}

 

instead of the   *d = A + ((*s A) +7) %26);   

you can have:

 

{

*d = *s + 7;

if(*d > z)

                  d-=26;

}

 

 

//function that counts vowels

int CV(char *s)

{

                  int r = 0;

                  while(*s)

                  {

                                    if(*s == A || *s == E || *s == I || *s == O || *s == U)

                                                      r++;

                                    s++;

                  }

                  return r;

}

 

Announcements and Notes:

 

.h files have function names and descriptions

 

when I doubt of order of operations, use parentheses

 

All tests are open book.

 

Stacey is going to run WINE in Cygwin in WINE in Cygwin   and then she will find a bit pattern in all of the vowelsof every language

 

HOMEWORK ASSIGNMENT:

 

Read in a sequence of integers (scanf/printf), and print them in reverse order.

The sequence is terminated by a 0.

 

Do this both recursively, and non recursively.