Advertisement
Ne-Biolog

Untitled

May 20th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. void add_singer(int size_of_list_of_singers, Singer ** list_of_singers) {
  2. Singer *new_singer = (Singer*)malloc(sizeof(Singer));
  3. read_string(new_singer);
  4. list_of_singers = (Singer**)realloc(list_of_singers, (size_of_list_of_singers + 1) * sizeof(Singer*));
  5. list_of_singers[size_of_list_of_singers] = new_singer;
  6. puts(list_of_singers[size_of_list_of_singers]->name);
  7. }
  8.  
  9. int main()
  10. {
  11. Singer **list_of_singers = NULL;
  12. int size_of_list_of_singers = 0;
  13.  
  14. add_singer(size_of_list_of_singers, list_of_singers);
  15. size_of_list_of_singers++;
  16.  
  17. add_singer(size_of_list_of_singers, list_of_singers);
  18. size_of_list_of_singers++;
  19.  
  20. for(int i = 0; i < size_of_list_of_singers; ++i) {
  21. puts(list_of_singers[i] ->name);
  22. }
  23.  
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement