If we stored an array of 100 character.. like char a[100]; gets(a); after giving the input as 500 will it run or not? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

If we stored an array of 100 character.. like char a[100]; gets(a); after giving the input as 500 will it run or not?

17th Oct 2018, 5:00 AM
Nitika Raj
2 Answers
+ 2
Just in case you mean input that is 500 characters long, yes it runs, but it will most likely overwrite other variables or code and corrupt the stack, causing the program to crash. This is why you shouldn't use gets as it is a huge security hole.
17th Oct 2018, 8:28 AM
Dennis
Dennis - avatar
0
yes 500 will run a confusion is if a[100] then how will it run on 500.. actually I don't know array.. that's why great confusion is there
17th Oct 2018, 6:14 AM
Nitika Raj