last day (14 days later) » 

9:51 AM
2
A: Multiple inputs to one string

IgorAllocate memory for inputFood, for example 100 chars: inputFood = malloc(100); and make allFood an array, not a char: char allFood[1000]; Because of that you will need to use strcat indstead of strcpy like this: strcat(allFood, inputFood); And in scanf add a blank space to consume traili...

 
scanf(" %s", inputFood); is the same meaning as scanf("%s", inputFood);.
 
@BLUEPIXY same meaning, but in practice it is crucial to avoid '\n' which is left in stdin. I recommend using fgets, or other instead of scanf
@haris When you do strcpy on a string it will always rewrite what you already have, so it is better to use strcat in this case.
 
This is a pointless comment if you know it. It should be indicated field width rather than that. e.g scanf("%99s", inputFood);
 
@BLUEPIXY Please speak so I can understand you. What is a pointless comment?
 
And in scanf add a blank space to consume trailing \n. this is.
 
9:51 AM
Do you understand how it works?
 
Do you understand how %s works?
 
Yes I do, do you?
 
Yes I do, do you?
 
Yeah I do, do you understand why I add space before %s?
 
It is not necessary.
 
9:52 AM
really?
 
sure.
 
Ok, I understand
You win
Yes you win, do you?
Or do you not?
 

last day (14 days later) »