The warning tells you that the read formatter is char* which come from the %s, but the place where you’re holding the value is a struct crPlayList *, soon it will not work as expected as they are completely different types and will result in undefined behavior.
struct crPlayList *aux;
scanf("%s", aux);
// | |-----------> tem struct crPlayList *
// |---> espera char*
You have two solutions, but they depend a little on what you want to do.
If you are reading only a text, such as the name of the song, to search in the list then you must transform the reading variable into an array of char (renamed to nomeProcura for clarity):
char nomeProcura[120];
scanf("%s", nomeProcura);
If you are trying to read a song’s data to insert into the list, you need to read each field individually and save to the correct location:
struct crPlayList *novaMusica = malloc(sizeof(struct crPlayList));
printf("Insira o nome da nova musica\n");
scanf("%s", novaMusica->music);
printf("Insira o cantor da nova musica\n");
scanf("%s", novaMusica->singer);
printf("Insira a duração da nova musica\n");
scanf("%s", &(novaMusica->mustime));
novaMusica->next = NULL;
But the idea of that
scanfwas reading the music data ? If yes which ones (since there are several)? But fundamentally the problem is that can not read onestruct crPlayListwithscanf("%s").– Isac
1- The idea was to do a name search and then list the correspondents. 2 - How can I read then? Or there is no way to read from the position itself?
– Luiz Roberto Furtuna
scanfread from the console, soon you are introducing a new song I suppose. In thisscanfwhich has Warning you wanted to read the 3 fields of the structure ? to create a new music ? Or thatscanfis to read a song name to do the search ? Upon what you are trying to do so the solution differs.– Isac
The
scanfis to read what was typed, and on top of that, search in the fieldmusic. I have a while loop, which when it finds correspondents, prints on the screen.– Luiz Roberto Furtuna
while (aux != NULL){
 if (music == aux->music){
 printf("\nMusica %s encontrada!\n\n", aux->music);
 printf("musica: %s", aux->music);
 printf("cantor: %s\n\n", aux->singer);
 return;
 }else{
 aux = aux->next;
 }
 }– Luiz Roberto Furtuna
So if that
scanfis to read the name of a song is just change the type of theauxfor achar aux[120]for example.– Isac
I changed my code. I realized that I had created a variable to store, ams was not using:
char busc[120];
 printf("\nDigite o nome da música:");
 scanf("%s", busc);
 
 while (aux != NULL){
 if (busc == aux->music){
 printf("\nMúsica %s encontrada:\n\n", aux->music);
 printf("Música: %s", aux->music);
 printf("Cantor: %s\n\n", aux->singer);
 printf("Duração: %f\n\n", aux->mustime);
 return;
 }else{
 aux = aux->next;
 }
 }. It does not return me the message, but it rotates and does not find record by name. Remembering, there is aaux = start;before– Luiz Roberto Furtuna
This will certainly be another problem than what you have in the question, and it will only be possible to answer seeing a lot more code of the program. I advise to open another question regarding this new problem. I answer this here to close it and have a solution posted here
– Isac
Ok. I will open a new question, and comment the link of the same here
– Luiz Roberto Furtuna
https://answall.com/questions/381252/while-não-encontra-correspondecia-linguagem-c
– Luiz Roberto Furtuna
@Itwasn'tme Yes it’s true, I’ve taken the tag
cmd– Isac
Ball show!
– It Wasn't Me