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


Problem in declaring vector,Runtime error

The link to my code is

Why am i getting runtime error. the above code is solution of question

Thanks in advance.

asked 16 Jul '16, 01:32

buffy20's gravatar image

accept rate: 0%

the problem is in your multiple function not in declaration.. if you try to run your main only by commenting your multiple function you will see the output "in main"


answered 16 Jul '16, 01:54

naksh9619's gravatar image

accept rate: 12%

on dev c++, I could even see some chk0 printed.chk0 which are before the assignment flag[val]=1 get printed and after that code stops working.

(16 Jul '16, 02:48) buffy203★
  1. Your multiple function returns an std::string but you haven't used the return value. Though this is not the reason of the runtime error, still it will give a warning.

  2. In line number 16 and 18, you are doing flag[val] = 1, where val = 1 according to your code. However, your vectors are still of size 0, so you are accessing memory out of bounds, which gives you RTE.

Have a look at this code of yours. I have removed the RTE, but have not touched your solution: Corrected code


answered 16 Jul '16, 05:49

sahilarora.535's gravatar image

accept rate: 0%

Got it. Thanks a lot.

(16 Jul '16, 12:53) buffy203★
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: 16 Jul '16, 01:32

question was seen: 1,371 times

last updated: 16 Jul '16, 12:53