30.1.3
This commit is contained in:
parent
38fbd0d2a8
commit
06683f9a75
47
adrdruck.c
Normal file
47
adrdruck.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
char name[50], vorname[50], strasse[50], hausnummer[50], plz[50], wohnort[50], telefon[50], fax[50];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
char *filename = "adresse.txt", *ptr;
|
||||||
|
printf("Dieses Programm liest eine Adresse ein und schreibt\ndiese Adresse n mal in die Datei 'adresse.txt'\n");
|
||||||
|
|
||||||
|
printf("Vorname:");
|
||||||
|
fgets(vorname, sizeof(vorname), stdin);
|
||||||
|
printf("Nachname:");
|
||||||
|
fgets(name, sizeof(name), stdin);
|
||||||
|
printf("Strasse:");
|
||||||
|
fgets(strasse, sizeof(strasse), stdin);
|
||||||
|
printf("Hausnummer:");
|
||||||
|
fgets(hausnummer, sizeof(hausnummer), stdin);
|
||||||
|
printf("Postleitzahl:");
|
||||||
|
fgets(plz, sizeof(plz), stdin);
|
||||||
|
printf("Wohnort:");
|
||||||
|
fgets(wohnort, sizeof(wohnort), stdin);
|
||||||
|
printf("Telefon:");
|
||||||
|
fgets(telefon, sizeof(plz), stdin);
|
||||||
|
printf("Fax:");
|
||||||
|
fgets(fax, sizeof(fax), stdin);
|
||||||
|
|
||||||
|
printf("Wie oft soll Adresse in Datei geschrieben werden:");
|
||||||
|
scanf("%d", &n);
|
||||||
|
|
||||||
|
ptr = strchr(strcat(vorname, name), '\n');
|
||||||
|
ptr[0] = ' ';
|
||||||
|
ptr = strchr(strcat(strasse, hausnummer), '\n');
|
||||||
|
ptr[0] = ' ';
|
||||||
|
ptr = strchr(strcat(plz, wohnort), '\n');
|
||||||
|
ptr[0] = ' ';
|
||||||
|
|
||||||
|
FILE *fp = fopen(filename, "w");
|
||||||
|
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
|
||||||
|
fprintf(fp, "%s%s%s\nTel. %sFax %s", vorname, strasse, plz, telefon, fax);
|
||||||
|
fprintf(fp, "--------------------------------------------------\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
}
|
28
adresse.txt
Normal file
28
adresse.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Alexander Fleischmann
|
||||||
|
Bergenstrasse 172a
|
||||||
|
50636 Nordhofen
|
||||||
|
|
||||||
|
Tel. 1233/213213
|
||||||
|
Fax 9808/89798
|
||||||
|
--------------------------------------------------
|
||||||
|
Alexander Fleischmann
|
||||||
|
Bergenstrasse 172a
|
||||||
|
50636 Nordhofen
|
||||||
|
|
||||||
|
Tel. 1233/213213
|
||||||
|
Fax 9808/89798
|
||||||
|
--------------------------------------------------
|
||||||
|
Alexander Fleischmann
|
||||||
|
Bergenstrasse 172a
|
||||||
|
50636 Nordhofen
|
||||||
|
|
||||||
|
Tel. 1233/213213
|
||||||
|
Fax 9808/89798
|
||||||
|
--------------------------------------------------
|
||||||
|
Alexander Fleischmann
|
||||||
|
Bergenstrasse 172a
|
||||||
|
50636 Nordhofen
|
||||||
|
|
||||||
|
Tel. 1233/213213
|
||||||
|
Fax 9808/89798
|
||||||
|
--------------------------------------------------
|
Loading…
x
Reference in New Issue
Block a user