Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
With so little information about the problem, I'm not sure if the previous suggestion was the right one for your case. In simpler debugging cases a scattering of diagnostic print statements can be more appropriate.
Obviously, you have to use your skill and judgement to figure out where to put the print statements and what you want to print out, but you didn't want me to put you out of a job, did you?
And, if you are doing this to learn, you might be wanting to try every approach available to you, just for grins.
Yours was a fair question, and I tried to give you a fair answer.
If you're using an IDE to program C++ (for example, KDevelop or Eclipse on Linux, or Visual Studio on Windows), then you probably first want to learn more about your IDE's debugger.
If you're planning on programming C++ on Linux, then you'll almost certainly be using GCC (either directly, from a command line, or behind a GUI IDE). In this case, the command-line "GDB" is definitely a worthwhile tool to learn.
The *last* thing you want to do is rely on "printf" statements. Using them is inevitable. But there are usually better, more effective ways to debug. The trick is to expose yourself to the higher-level tools available (like GDB or Visual Studio), then fall back on "printf" only when you need to.
Thanks paul boss. But sorry to say that I haven't got the answer. I am using c++ on linux and i just want a command to debug a program.
like
command filename. I just want the command to debug a filename for errors and execution. Thanks.
I am using c++ on linux and i just want a command to debug a program. like command filename. I just want the command to debug a filename for errors and execution.
If you are expecting a command that you can run that will automagically remove bugs from an incorrectly written bit of code, then you are setting your expectations rather high.
In addition, maybe you should look at static analysis http://en.wikipedia.org/wiki/List_of..._code_analysis which may be closer to what you want. But you will still have work to do; the best that you can expect is that something will point out potential trouble areas and you will have to come up with a way of writing correct code that corresponds to your intentions.
My assumption is that your program is probably a fairly simple one, of the type that you might be set as a learning problem in the early stages of a programming course.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.