I am trying to write program which takes in song names, genres, and artists. The code to input these is this:
printf("Genre: ");
getStringFromUserInput(input, MAX_LENGTH);
length = strlen(input);
genre = (char*)malloc(length);
strcpy(genre, input);
getStringFromUserInput(input, MAX_LENGTH);
I have a function to initialize a new node, but when building the program it is giving me the warning.
Node *newNode(char songName, char artist, char genre, Node *link){
Node *new;
new = (Node *)malloc(sizeof(Node)); //dynamic memory allocation of 1 node
if(new!=NULL){
//if there is memory, inputs data into bucket
new->songName = songName;
new->artist = artist;
new->genre = genre;
new->link = link;
}
return (new);
}
Any help would be great, thanks!