C Lecture 3

[Previous Lecture] [Lecture Index] [Next Lecture]

Compiling Programs

To compile and link a C program: Machines to compile on: To start the debugger: See the web page for more details on using the compiler and debugger.

More on Strings

Variable definition char buf[1024]:

Variable definition char *ptr:


String routines

Note: only strdup() `creates' new memory!
All others use memory that is passed to them.

Logic Operators


Comparison Operators


Arithmetic Operators


Assignment Operators


Misc Operators

Program fragment:
    factorial = 1;
    for (i = 0; i < 10; i++) {
	if (i)
	    factorial *= i;
        printf("factorial of %d is %d\n",
            i, factorial);
    }
Modified program fragment:
    for (factorial = 1, i = 0; i < 10; i++) {
        factorial *= i ? i : 1;
        printf("factorial of %d is %d\n",
            i, factorial);
    }

Bit Operators

all operands must be int
[Previous Lecture] [Lecture Index] [Next Lecture]