Question:
I am beginning to learn C in my spare time and have a couple of questions.?
anonymous
2010-01-28 09:27:05 UTC
First: I would like if some one could link me to a tut about how to make a program were the header and footer stays where it is but a list in the center scrolls(and would be nice if it included keyboard support and the ability to highlight lines as selected).

Second: It would be nice if some one linked me to a tut about file I/O.

Thanks

RMDan
Five answers:
jplatt39
2010-01-28 10:54:17 UTC
I have a problem with Macadamean's answer. What you have to understand for the first question is that that is low-level hardware control stuff you are asking. By design his stuff is not part of the C or C++ standard, but is always handled (except for some very basic stuff) by external libraries which either are provided by another vendor or which a programmer writes him or herself. He links to the graphics libraries, but graphics cards didn't become available on computers (till the seventies for corporations and the late eighties for individuals).



The basic input/output libraries are stdio.h for C and iostream for C++. To go beyond that in text mode, which is less complicated than graphics programming you need either curses or conio.h for EITHER C or C++. Conio.h was a Borland addition quickly copied by all the other Windows compiler vendors. Curses is a Unix Library which got it start back around 1980 in academia, and is therefore among the many programs which Linux inherited. There are two versions around now. Ncurses is mainly for Unix and Unix-derived OSes. pdcurses is the version which runs on Windows (though there is a Windows version of it. Conio.h is probably included in your compiler if you are on Windows. You can get curses for free (you have to compile it but you will be using a prewritten make file which means you edit it and type "make"). All this presupposes you are willing to use a text editor like Notepad and keep a console window open to compile from. You can even organize Visual C++ to compile from the command line if that is what you want. When you are just starting out it is actually much easier than using an IDE and learning about project files and all. Digital Mars C Compiler is actually an excellent free C compiler (with an IDE available on CD for $54). Get it at http://www.digitalmars.com .



I've linked to some tutorials for file handling in sources, along with a tutorial in curses and a discussion of tutorials for conio.h. Once again though, you probably already have conio.h
Mantis
2010-01-28 18:16:39 UTC
Sure. What you want is Win32 programming. In a windows program what you're trying to do isn't all that hard at all. Unfortunately, Windows programming itself is a little intimidating to get into at first--it can take a few pages of code just to set up your program and create your first window. Creating a dialog box with a scroll box isn't too hard after that, but it's the up-front work that keeps so many programmers in console windows.



I always believe that people learn programming better if they have a goal, so by all means keep the program you're thinking of writing in the back of your mind. But for now I'd start with the basics. Once you are comfortable with the basic language there are many good tutorials and books (many at your local library, I'm sure) that'll get you into Windows programming.



Good luck, and keep coding.
deonejuan
2010-01-28 17:52:46 UTC
c is all about linking libraries. the GTK+ toolkit comes closest to the metal with the c. QT is c++, as is wxWidget. Both of the last two require that you code c++ wrappers to callback c library functions. Not hard, but frustrating when you are having to learn 3 things at once. You should google GTK+ and read.



lately, I've discovered OpenCV which is primarily geared for machine vision. There is one API that lets you draw in a window. That's all I need. I would not recommend this approach to just everyone.



I'm fascinated with the speed c can do and I have no desire to wade back into c++. There are other bridges for GUI to c, including java/JNI, Python and Perl.
Macadameane
2010-01-28 17:36:23 UTC
What you are asking is very difficult to do. You would need to use a gui library like GTK or QT to do stuff like this. Both sites have a lot of documentation about making scrollable boxes as you describe. Its hard for seasoned programmers to hand code these. I wouldn't recommend it for a beginner.



If you are just playing around and want this kind of result, use a web page instead. HTML offers ways to have a set box size that will scroll.



This HTML/CSS code will allow something like this:



Top of page



Insert stuff here to see inside the box



Bottom of page



If the content inside the box is not enough, it will simply not scroll.



Sites:

http://www.cplusplus.com/doc/tutorial/files/ - File Input/Output

http://qt.nokia.com/products - QT

http://www.gtk.org/ - gtk

http://www.gtk.org/tutorial1.2/gtk_tut-10.html - gtk boxes

http://doc.trolltech.com/4.4/qscrollarea.html - Qt scroll area docs
anonymous
2010-01-28 18:01:03 UTC
You're learning "hammer" without learning "carpentry", so you know to bang, but not why or on what.



Learn computer programming first, and when you start learning a language to do it in, you'll already have the answers to your questions. http://www-old.oberon.ethz.ch/WirthPubl/AD.pdf


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...