mirror of
https://github.com/theoleuthardt/learningC.git
synced 2026-06-13 09:37:53 +00:00
Initial commit
This commit is contained in:
commit
826d4c8c9d
81 changed files with 7268 additions and 0 deletions
31
uebung6/aufgabe4.c
Normal file
31
uebung6/aufgabe4.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
|
||||
int main() {
|
||||
// A4: Datei einlesen zum Auslesen von Lottozahlen zu einem bestimmten Datum
|
||||
FILE *fptr = fopen("../Lottozahlen.txt", "r");
|
||||
if (fptr == NULL) {
|
||||
printf("Not able to open the file.\n");
|
||||
return 1;
|
||||
}
|
||||
char input[11];
|
||||
char s[11];
|
||||
char m[11];
|
||||
printf("Datum eingeben: ");
|
||||
gets(input);
|
||||
while (fgets(s, 11, fptr)) {
|
||||
if (strcmp(s, input)==0) {
|
||||
printf("Datum gefunden\n");
|
||||
printf("Lottozahlen vom %s: ", s);
|
||||
fgets(m, 99, fptr);
|
||||
fgets(m, 99, fptr);
|
||||
printf("%s", m);
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
fclose(fptr);
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue