Exercise 1-22 in the K&R. What error is responsible?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
So the problem that I'm running into now is using GDB (with emacs or even just by itself) and not being able to accept user input from stdin. I'll keep searching stack exchange and other sites for how to do this but if you know how to accomplish this (and I strongly suspect that you do), it would be a welcomed advancement.
When you use gdb through emacs you'll get an input/output buffer that you can use for providing stdin and reading stdout. It's a little clunky but it works. Best bet is to split your emacs screen into 3 so you can see, source, in/out and the gdb control window all at the same time.
The other option is to connect it to external ttys: which was described in the link rtmistler provided above, but unless you're doing some terminal programming (using escape sequences, or ncurses) that'll likely be more trouble than its worth.
This all started with a segmentation fault. That should be easy to track down by inspecting the core file in the debugger. Backtrace on the core file.
I agree that normal validation is faster using print statements.
Also agree that designing a solution in advance of coding is the right thing to do. Too many people get too distracted by simple code tasks as opposed to the problem and solution.
When you use gdb through emacs you'll get an input/output buffer that you can use for providing stdin and reading stdout. It's a little clunky but it works. Best bet is to split your emacs screen into 3 so you can see, source, in/out and the gdb control window all at the same time.
The other option is to connect it to external ttys: which was described in the link rtmistler provided above, but unless you're doing some terminal programming (using escape sequences, or ncurses) that'll likely be more trouble than its worth.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.