Advertisement
Guest User

pointers and structs

a guest
Mar 31st, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct waffle
  5. {
  6.     char *name;
  7.  
  8. } waffle;
  9.  
  10. waffle *scan(int *number);
  11.  
  12. int main(void)
  13. {
  14.   waffle nom;
  15.   int count=0;
  16.      
  17.  
  18.   nom = scan(&count);
  19.  
  20.   printf("count is :%d", count);
  21.  
  22.  
  23.     return 0;
  24. }
  25.  
  26. waffle *scan(int *number)
  27. {    
  28.     int i;
  29.     waffle *syrup;
  30.     char *buff;
  31.    
  32.     for (i = 0; i <5; i++)
  33.     {
  34.         printf("Name first waffle:\n>");
  35.         scanf("%s", buff);
  36.            
  37.         syrup[i].name = (char*) calloc( strlen(buff+1), sizeof(char) );
  38.     }
  39.  
  40.     return syrup;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement