====== C-Programmierung ====== ===== Die Sprache ===== ==== Konsolenausgabe ==== ^ Format String (%) ^ erwarteter Wert ^ Erklärung ^ | d, i | int | decimal number | | e, E | double | [-]d.ddde±dd where d is a decimal digit and [-] means a minus sign is printed if the value is negative. | | f, F | double | [-]ddd.ddd | | g, G | double | esentially acts as a f or e specifier, whichever is more compact. | | c | char | a single character | | s | char * | a string | | p | address in RAM | prints out the address of a variable, e.g. printf("text %d",variable); -> text 001AfC00 | ==== Konsole einlesen ==== Mit der Funktion "scanf" kann eine Konsolenzeile eingelesen werden. Die Funktion ist das Gegenstück zu "printf" und verhält sich auch entsprechend umgekehrt. Das folgende Beispiel verdeutlicht die Funktion: #include void main(void){ int val; printf("Bitte eine Zahl eingeben!"); scanf("%d", &val); // Hier wird der Eingabewert vom Typ int an die Adresse von val geschrieben printf("Die eingegebene Zahl vom localhorst lautet: %d\n",val); } ===== Linksammlung ===== [[http://www.exforsys.com/tutorials/c-language/c-programming-an-overview.html| Tutorial in C Programming]]