update
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
|
||||
char *statS = "Hallo PdP";
|
||||
char dynS[10] = "Hallo PdP";
|
||||
|
||||
printf("stat Buchstabe an 2. Stelle: %c \n", dynS[1]);
|
||||
printf("dyn. Buchstabe an 2. Stelle: %c \n", statS[1]);
|
||||
|
||||
//dynS[1] = 'e';
|
||||
//printf("dyn Buchstabe an 2. Stelle verändert: %c \n", dynS[1]);
|
||||
|
||||
//statS[1] = 'e';
|
||||
//printf("stat Buchstabe an 2. Stelle verändert: %c \n", statS[1]);
|
||||
|
||||
statS = "neuer String";
|
||||
printf("stat Buchstabe an 2. Stelle verändert: %c \n", statS[1]);
|
||||
|
||||
dynS = "neuer String";
|
||||
printf("dyn. Buchstabe an 2. Stelle verändert: %c \n", dynS[1]);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/* char_array.c
|
||||
*
|
||||
* Entscheidung, ob eine Zeichenkette ein 'a' enthaelt
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#define MAX 40
|
||||
|
||||
int main() {
|
||||
int index;
|
||||
char eingabe [MAX];
|
||||
|
||||
printf("Bitte String eingeben (max. %d Zeichen): ", MAX-1);
|
||||
fgets(eingabe, MAX, stdin);
|
||||
|
||||
printf("\nEingabe: %s", eingabe);
|
||||
|
||||
for (index = 0; eingabe[index] != '\0'; index++)
|
||||
if (eingabe[index] == 'a')
|
||||
break;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/* char_array.c
|
||||
*
|
||||
* Entscheidung, ob eine Zeichenkette ein 'a' enthaelt
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#define MAX 40
|
||||
|
||||
int main() {
|
||||
int index;
|
||||
char eingabe [MAX];
|
||||
|
||||
printf("Bitte String eingeben (max. %d Zeichen): ", MAX-1);
|
||||
fgets(eingabe, MAX, stdin);
|
||||
|
||||
printf("\nEingabe: %s", eingabe);
|
||||
|
||||
for (index = 0; eingabe[index] != '\0'; index++){
|
||||
if (eingabe[index] == 'a'){
|
||||
printf("Der String enthält an Position %d ein 'a' \n", index );
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (eingabe[++index] == '\0'){
|
||||
printf("Der String enthält kein 'a'");
|
||||
}
|
||||
else {continue;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,31 +0,0 @@
|
||||
/* fehler.c
|
||||
*
|
||||
* Ein Programm, dass Compilerfehler,
|
||||
* Laufzeitfehler und logische Fehler demonstriert.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
|
||||
int num1, num2;
|
||||
num1 = 0;
|
||||
num2 = 1;
|
||||
int temp;
|
||||
|
||||
printf("Der Quotient der Variablen ist: "); //Sytnaxfehler ; einfügen
|
||||
printf("%d\n", num1/num2);
|
||||
printf("\n"); // Syntaxfehler: Anführungzeichen fehlten
|
||||
|
||||
printf("Jetzt werden die Variablenwerte vertauscht.\n");
|
||||
|
||||
// Dies muss korrigiert werden. (logischer Fehler!!!)
|
||||
temp = num1;
|
||||
num1 = num2;
|
||||
num2 = temp;
|
||||
|
||||
printf("Der Quotient der Vaiablen ist nun: ");
|
||||
printf("%d\n", num1/num2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#define MAX 100
|
||||
|
||||
int main(){
|
||||
|
||||
char s1[MAX];
|
||||
char s2[MAX];
|
||||
char name[2*MAX];
|
||||
int index;
|
||||
|
||||
// AUffordeurng Eingabe Name
|
||||
printf("Gebe deinen Vornamen an: \n");
|
||||
fgets(s1, MAX, stdin);
|
||||
printf("Gebe deinen Nachnamen an: \n");
|
||||
fgets (s2, MAX, stdin);
|
||||
|
||||
// ob Vorund Nachname verschieden oder gleich sind
|
||||
int rvalue = strcmp(s1, s2);
|
||||
if (rvalue == 0){
|
||||
printf("Namen sind gleich \n");
|
||||
}
|
||||
else {
|
||||
printf("Strings sind ungleich \n");
|
||||
}
|
||||
|
||||
// Großschreibung Nachname
|
||||
for (index = 0; ((s2[index]) != '\0'); ++index){
|
||||
if ((int)s2[index] >= 97 && (int)s2[index] <= 122){
|
||||
s2[index] = (int) s2[index] - 32;
|
||||
}
|
||||
else{continue;}
|
||||
}
|
||||
// printf("großgeschriebener Nachname: %s \n", s2);
|
||||
|
||||
// Vorname NACHNAME String
|
||||
int len_s1 = strlen(s1);
|
||||
if (len_s1 > 0 && s1[len_s1 - 1] == '\n') {
|
||||
s1[len_s1 - 1] = ' ';
|
||||
}
|
||||
else {}
|
||||
strcpy(name, s1);
|
||||
strncat(name, s2, 2*MAX);
|
||||
printf("%s", name);
|
||||
|
||||
// Länge von Namen
|
||||
int len_letters = 0;
|
||||
for (index = 0; name[index] != '\0'; ++index){
|
||||
if ((name[index] >= 'A' && name[index] <= 'Z') || (name[index] >= 'a' && name[index] <= 'z')){
|
||||
len_letters ++;
|
||||
}
|
||||
else{continue;}
|
||||
}
|
||||
printf("Länge des Names: %d \n", len_letters);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user