runtime error

am getting runtime error in following code
http://ideone.com/rS5iE

the code is perfectly fine syntax wise because i ran it on dev c++ and it ran successfully. But on dev also..the code is running only for one input and not for multiple inputs. Maybe u can figure the error out.

the problem is:
http://www.codechef.com/problems/ONP
When you read this article:

http://www.cplusplus.com/articles/iwTbqMoL/

you will know how to debug, and then you will have no trouble discovering that '\0' means the value 0, and '/0' is two characters. Also, if your compiler did not warn you that you were trying to treat the two characters /0 as a single character, throw it away and get one written in the last decade.
For run time errors, your best bet is to learn how to use the debugger. Have a watchlist of your variables, see how they change as you step through the code, 1 line at a time.

HTH
Does while(1) ever finish?
@kevin.. yes while(1) will finish because i have included a break statement which will be executed for sure( coz of concept used)..

@moschops- thank you so much. And could you please tell me the best compiler i should use. As of now..i have been using dev c++ 4.9.9.2

thank you guys
I use KDevelop IDE on linux, and QtCreator IDE, both of which use gcc compiler. Qt is availible of windows and mac, so that might suit you better if you don't have linux.

Maybe you need to turn on all the warning flags for whatever compiler you use at any stage. For gcc, I have -Wall -Wextra & -pedantic turned on all the time.

If you are serious about computing - get linux. It's free, has literally 10's of 1,000's of apps to down load - you can go completely nuts with almost anything you like. There are lots of advantages - check it out.

You will need a spare hard drive or at least a spare partition. Get a removable hard drive bay, if you have a PC, then you can chop & change as much as you want.

HTH
Dev C++ isn't a compiler. It is an IDE. It's important to know the difference. Anyway, here's an article talking about it:

http://www.cplusplus.com/articles/36vU7k9E/
will i learn coding better with linux??
coz my main aim is to become a good coder and if linux can do me a favour..m surely gonna get that..but if it is just gonna consume my time learning it..then i need to think again..i'd like ur opinion on that :)
Another thing:

if((string[j]=='(')||(string[j]=='+')||(string[j]=='-')||(string[j]=='*')||(string[j]=='/')||

That looks like an error with the || on the end.

Apart from that, your code will be more scalable (say you add lots of new operators) if write a IsOperator function with a switch that checks the argument against all the valid operators, returns a true if it is, false otherwise.
Linux gives you access to all sorts of things, and experience with a UNIX like OS is a good thing when it comes to getting a job.

If you can learn how to do make yourself rather than relying on an IDE, that is also a huge bonus. The linux way is to learn how things work, not just use tools all the time. Sure , using tools is fine - you have to get things done, but it is a real bonus if you know how it all works behind the scenes.
Topic archived. No new replies allowed.