You are not logged in. Please login at to post your questions!


run time error

this is my code in C.I am getting a run time error. Please help me out.

asked 24 Jul '18, 07:44

jayantika23's gravatar image

accept rate: 0%

Hmm..there are several mistakes in your code-
1.Run Time Error(SIGSEGV) - due to gets() fuction (WHY - refer this link -
). Use scanf() instead of gets() or anything else.

2.Even after using scanf() you will get NZEC(Non Zero Exit Code) error, why because at the end of main() function you have return 1 instead of return 0.

3.Now you will get wrong answer because-
I-Max size of string given by you is 100 inside struct which is equal to constraint given in the question. It may lead to overflow. Remember always declare size more than the constraint. Here declaring size 102 gives AC. (see the solution link given below)

II.You should check the output before submitting. There was no newline comment in printf() function in your code causing WA. printf("%s\n", aa[k].s).

Well as a newbie your logic was really nice but using structure to store all the test cases and solving them offline is not a good strategy always. You should check other solutions and learn the basic format of a solution code used in competitive coding.
Happy coding:) link:solution


answered 24 Jul '18, 16:37

pant0000's gravatar image

accept rate: 10%


answered 16 Aug '18, 17:15

knightware101's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 24 Jul '18, 07:44

question was seen: 148 times

last updated: 16 Aug '18, 17:15