Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main(void)
  6. {
  7. //int i =0;
  8.     int *zahlen;
  9.     int len;
  10.     printf("Bitte anzahl der Werte eingeben\n");
  11.     scanf("%d",&len);
  12.     getchar();
  13.     zahlen=(int*)malloc((sizeof(int)*len));
  14.     for(int i=0; i<len; i++)
  15.     {
  16.         printf("\n Zahl %d:",i);
  17.         scanf("d",&zahlen[i]);
  18.         getchar();
  19.     }
  20.     if (zahlen==NULL)
  21.     {
  22.         printf("Fehler beim Speicher reservieren!");
  23.         return 1;
  24.     }
  25.     for(int i=0; i<len; i++)
  26.     {
  27.         printf(",%d",zahlen[i]);
  28.     }
  29.  
  30.     free(zahlen);
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement