Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. #pragma warning(disable:4996)
  6.  
  7. int getSongInfo(struct songInfo *pFillInfo, char artistName, char songName);
  8.  
  9. struct songInfo {
  10.  
  11. char *songArtist;
  12. char *songTitle;
  13. };
  14.  
  15. int main(void)
  16. {
  17. struct songInfo *fillPtr, songList[10][30];
  18. fillPtr = &songList[30][0];
  19.  
  20. char tempArtist[30][10];
  21. char tempSong[30][10];
  22.  
  23. int counter = 0;
  24. while (counter != 10)
  25. {
  26. printf("Please enter the artist name: ");
  27. fgets(tempArtist[counter], strlen(tempArtist[counter]), stdin);
  28. printf("Please enter the song name: ");
  29. fgets(tempSong[counter], strlen(tempSong[counter]), stdin);
  30.  
  31. getSongInfo(fillPtr, tempArtist[strlen(tempArtist[counter])][counter], tempSong[30][0]);
  32. fillPtr++;
  33. counter++;
  34.  
  35. }
  36. }
  37.  
  38. int getSongInfo(struct songInfo *pFillInfo, char artistName, char songName)
  39. {
  40. pFillInfo->songArtist = (char*)malloc(strlen(&artistName) + 1);
  41. pFillInfo->songTitle = (char*)malloc(strlen(&songName) + 1);
  42.  
  43. strcpy(pFillInfo->songArtist, &artistName);
  44. strcpy(pFillInfo->songTitle, &songName);
  45.  
  46. free(pFillInfo->songArtist);
  47. free(pFillInfo->songTitle);
  48.  
  49. return 1;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement