0

When the number of the input(character) is bigger than the input- C

How come this piece of code can handle the input as big as 100 and more? Because in the mgetline function there is a condition i< 4. Can you explain that? Also I'd like to ask if we change the size of the line as line[5] what will happen when there is a input as big as 10? As far as I know for the latter the program tries to override a completly unrelated word document. These two questions about the size of the string and the computer's behaviour when there is an inconvenience. Thanks in advance. The code: https://code.sololearn.com/cW2nuiu5Q9fr/#c

9th Feb 2020, 2:26 PM
mert aydın
1 Resposta
+ 3
mgetline indeed only reads four chars but it is called from the while loop so it reads 4 chars, then another 4 chars and so on. Therefore reading 100 chars or more is no problem. This also means that line can be declares as line[5] because the maximum amount of chars stored is 5 (4 for text plus one for '\0').
9th Feb 2020, 4:25 PM
Aaron Eberhardt
Aaron Eberhardt - avatar