Tutorials Multimedia in the Net

Winter Semester 2006/2007

Freqently Asked Questions & Recommendations

Raphael Wimmer <raphael.wimmer@medien.ifi.lmu.de>


What we will cover today

Exercise 3 review

Some Recommendations

Frequently Asked Questions

C pitfalls [1]

Windows C vs. Linux C.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

char *colour;

int main(int argc, char *argv[]){

	scanf("%s",&colour);

	if (strcmp(colour,"blue")){
		printf("DATE:"__DATE__);
	}
}

C pitfalls [2]

Flexible Arrays

int main(int argc, char** argv) {

    int numcolors;
    char* colors[numcolors];
    if(argc == 2) { // if argument given
        // init colors
        numcolors = 3;
        colors[0] = "red";
        colors[1] = "green";
        colors[2] = "blue";
    }
}

C pitfalls [3]

String Comparison

#include <stdio.h>
int main(int args, char** argv) {

	char* string = "..."
	if (argv[1] == "blue") {
		printf("\033[34;1m");
		printf(string);
	} else if (argv[1] == "green") {
		printf("\033[42;1m");
		printf(string);
	} else if (argv[1] == "red") {
		printf("\033[31;1m");
		printf(string);
	}
 
	printf("\033[0");
 
	return 0;
}