Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. // 1: neue Adresse
  2. // 2: alle Adressen anzeigen
  3. // 3: Adresse ändern
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7.  
  8. typedef struct adresse_ {
  9. char name[50];
  10. char strasse[50];
  11. int hausnummer;
  12. char stadt[50];
  13. int plz;
  14. }adresse;
  15.  
  16. int eingabe, i;
  17.  
  18. static void start_ausgabe () {
  19. printf("Bitte wählen Sie eine folgenden Moeglichkeiten:\n\n");
  20. printf("Möglichkeit [1] = Neue Adresse eingeben.\n");
  21. printf("Möglichkeit [2] = Adresse anzeigen.\n");
  22. printf("Möglichkeit [3] = Adresse ändern.\n");
  23. printf("Möglichkeit [4] = Verlassen.\n");
  24. }
  25.  
  26. static void adresse_eingabe (adresse *in) {
  27. printf("Eintrag = %d\n", i);
  28. printf("Name: ");
  29. scanf("\t%s", &in->name);
  30. //printf("\n");
  31. printf("Straße Hausnummer: ");
  32. scanf("\t%s %d", &in->strasse, &in->hausnummer);
  33. //printf("\n");
  34. printf("PLZ Stadt: ");
  35. scanf("\t%d %s", &in->plz, &in->stadt);
  36. printf("\n");
  37. }
  38.  
  39.  
  40.  
  41. static void print_adresse (adresse out[i]) {
  42. printf("Adresse:\n", out[i].name);
  43. printf("%s\n%s", out[i].name);
  44. printf("%s %d\n",out[i].strasse, out[i].hausnummer);
  45. printf("%d %s\n\n", out[i].plz, out[i].stadt);
  46. }
  47.  
  48. int main (){
  49. int eingabe2, number;
  50. adresse new[i];
  51. do {
  52. start_ausgabe();
  53. scanf("%d", &eingabe);
  54. printf("\n");
  55.  
  56. switch (eingabe) {
  57. case 1:
  58. i++;
  59. adresse_eingabe(&new[i]);
  60. //print_adresse(new);
  61. break;
  62. case 2:
  63. printf("Welche Adresse wollen Sie sehen? ");
  64. scanf("%d", &number);
  65. printf("Nummer = %d\n", number);
  66. printf("\n\n");
  67. print_adresse(&new[number]);
  68. break;
  69. case 3:
  70. break;
  71. case 4:
  72. printf("Bye!\n");
  73. return 0;
  74. break;
  75. default:
  76. break;
  77. }
  78. printf("Wollen Sie fortfahren?\n[1] = JA\n[0] = NEIN\n");
  79. scanf("%d", &eingabe2);
  80. printf("\n");
  81. if (eingabe2 == 0) {
  82. printf("Bye!\n");
  83. return 0;
  84. }
  85. } while (eingabe != 4);
  86. printf("Bye!\n");
  87. return 0;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement