Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #pragma warning(disable:4996)
- int getSongInfo(struct songInfo *pFillInfo, char artistName, char songName);
- struct songInfo {
- char *songArtist;
- char *songTitle;
- };
- int main(void)
- {
- struct songInfo *fillPtr, songList[10][30];
- fillPtr = &songList[30][0];
- char tempArtist[30][10];
- char tempSong[30][10];
- int counter = 0;
- while (counter != 10)
- {
- printf("Please enter the artist name: ");
- fgets(tempArtist[counter], strlen(tempArtist[counter]), stdin);
- printf("Please enter the song name: ");
- fgets(tempSong[counter], strlen(tempSong[counter]), stdin);
- getSongInfo(fillPtr, tempArtist[strlen(tempArtist[counter])][counter], tempSong[30][0]);
- fillPtr++;
- counter++;
- }
- }
- int getSongInfo(struct songInfo *pFillInfo, char artistName, char songName)
- {
- pFillInfo->songArtist = (char*)malloc(strlen(&artistName) + 1);
- pFillInfo->songTitle = (char*)malloc(strlen(&songName) + 1);
- strcpy(pFillInfo->songArtist, &artistName);
- strcpy(pFillInfo->songTitle, &songName);
- free(pFillInfo->songArtist);
- free(pFillInfo->songTitle);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement