8/28/2023 0 Comments Scanf in cPrintf("%s %d %s\n", actors.name, actors.BirthYear, actors. Strncpy(untry, token, sizeof(untry) - 1) Strncpy(actors.name, token, sizeof(actors.name) - 1) The scanf() function reads formatted input from the standard. Printf("%s %d %s\n", actors.name, actors.BirthYear, untry) Īlternatively you can use fgets and strtok char buf In C programming, scanf() is one of the commonly used functions to take input from the user. int n1 ĪctorBio* actors = malloc(sizeof(ActorBio)* n1) You also want to make sure the function succeeded, otherwise n1 is not initialized. There is still one \n character in the buffer, this will be read the next time. I want my struct ActorBio to save information correctly and to use scanfs instead of while loops. How should i change this part to scanf only name? I use scanf("%s\n", actors.name) to scanf until 34(asci code of "), but it just scanfs everything.Then i scanf int data and then country. Printf("%s %d %s\n",actors.name,actors.BirthYear,untry) I'm trying to scanf sql table without using scanf for every symbol, but my code outputs some kind of trash.ĪctorBio *actors = malloc(sizeof(ActorBio) * (n1 + 2))
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |