LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-03-2009, 11:56 AM   #1
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Rep: Reputation: 25
Newbie materials question


I can write programs for my math class, and do basic programs to manage data sets and whatnot. I can make newbie use of pointers and arrays, but I want to expand my knowledge.

Granted, all of the stuff I've learned so far has been through linux man pages, a few google searches, and trial and error.

I want to dig deeper, though, but I can barely understand what's going on in most of the .h files.

Also, I'd like to add a GUI for my programs in C, but I don't know where to start with that. I mean, my mental hangup on that issue is, "Well, say I design a GUI in some way, then I add the code to the buttons and bars and the like.. How will it compile?"

I'm looking for books, but not 9th edition typo-riddled and poorly worded books, but books that describe in detail the intricacies of the C language.


If you ever felt like one day you might want to pour out all your thoughts about C, learning C, and what C is good for, this is definitely the right time to do it =)

What's a good book on C?
What's a good book on the mechanics of algorithms?
What's a simple way to implement a UI to support a C program?
How can I better understand all that is contained within /usr/include?
 
Old 11-03-2009, 12:49 PM   #2
cantab
Member
 
Registered: Oct 2009
Location: England
Distribution: Kubuntu, Ubuntu, Debian, Proxmox.
Posts: 553

Rep: Reputation: 115Reputation: 115
To implement a GUI, you typically use a toolkit, which provides all the things like menus, buttons, and so on. The two major ones are Qt, written in C++ and used by KDE, and GTK+, written in C and used by Gnome. I don't think you can use Qt if you're writing C as opposed to C++ code.
 
Old 11-03-2009, 01:13 PM   #3
archlinux_jessica
Member
 
Registered: Aug 2009
Location: PA USA
Distribution: Arch Linux
Posts: 78

Rep: Reputation: 19
I think your on the right track. Being able to Google and look into the man pages is the most important lesson you can learn.

If your looking into GUI, I would suggest GTK or QT because your starting out. They are toolkits that utilize the native GUI system that your computer is running (WIN32 on Windows, X11 on Linux).

You can also look into X11 if your looking at basic low level GUI items.

I can't help too much on the books because I mainly learn from Google. All you need sometimes with Google is to just be pushed in the right direction.

Other things you can get into is Cario, which allows you drawing capabilities with GTK, X11, QT, and WIN32. If gaming graphics is what your looking for, I would suggest SDL for 2D graphics. SDL also comes with SDL_mixer for better audio capability, SDL_image to handle image compression, and many other extensions. OpenGL allows you to do 3D graphics, and can be mixed in with SDL to run together. SDL can also handle network capabilities with SDL_net, as well as text graphics with SDL_ttf.

QT has a GUI editor for making your forms graphically. GTK has Glade, which gives you a GUI editor for forms and exports what you make in a XML .glade file that you can read into your programming.

BTW a little off topic, you can also design the windows side of your programs using WINE. I installed Dev-Cpp on wine that uses GCC. The package manager worked just fine and I was able to use "wineconsole" to run the batch file I made to compile the program for Windows. And you can use #ifdef __WIN32__ (Might want to google it or look into the GTK source code for an example) to have the compile select the appropriate code for the Operating System your using (Or Wine'ing)


Hope that helped
-Jessica-
 
Old 11-03-2009, 01:14 PM   #4
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Quote:
Originally Posted by Dogs View Post
What's a good book on C?
I'll leave this one alone... I suspect there are as many answers as there are readers of this post.

Quote:
Originally Posted by Dogs View Post
What's a good book on the mechanics of algorithms?
"Introduction to Algorithms" (Cormen, et. al.) is a good one. The venerable "Algorithms in C" fits (imho) into that category you describe as "9th edition typo-riddled and poorly worded".

Quote:
Originally Posted by Dogs View Post
What's a simple way to implement a UI to support a C program?
Hmm... simple. That's a tall order. Tk is fairly quick to learn, and Tcl helps with rapid development. There are widget sets built on the X protocol that are far more flexible and detailed. Every developer has a preference, I suppose... I am fond of Motif, but it isn't very popular. Raw X widgets and many third-party widget set packages are widely available.

Quote:
Originally Posted by Dogs View Post
How can I better understand all that is contained within /usr/include?
I can't express strongly enough how pleased I am, personally, at your interest in the C preprocessor -- it is an all-too-frequently ignored or poorly studied aspect of the language.

There are some books on the subject but they're mostly out of date, I think the best resources can be found online via web searches. rms has a good basic description on the web somewhere (also dated, but still a good starting point). There are many more, choose ones that seem to make sense to you.

Last edited by raconteur; 11-03-2009 at 01:25 PM.
 
Old 11-03-2009, 02:30 PM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by Dogs View Post
I'm looking for books, but not 9th edition typo-riddled and poorly worded books, but books that describe in detail the intricacies of the C language.
I think for that, most people would recommend:
The C Programming Language, Second Edition
by Brian W. Kernighan and Dennis M. Ritchie.

http://en.wikipedia.org/wiki/The_C_P...age_%28book%29

aka. The White Bible

... Amen !
 
Old 11-03-2009, 05:09 PM   #6
Dogs
Member
 
Registered: Aug 2009
Location: Houston
Distribution: Slackware 13.37 x64
Posts: 105

Original Poster
Rep: Reputation: 25
Hmm.. The answers I've gotten so far are a bit mild, BUT they do generate new questions =)

If I may, I'd like to post pseudo code I wrote to the specs listed on my homework page for last week. It's the first one that finally made that switch in my head flip, and get me right and pissed off that I STILL can't quite visualize what the heck is happening there..

Specifically, I'm told there are 2 sensors, sensors being of the type than when a specified circumstance is "sensed" then a signal is generated, which is then read by my program. It's this process that I am most interested in. How do I READ from a sensor?


Within the code are two key issues I would love to understand..
First off, How to read from a sensor/pins on a USB port/Pins on a serial port/Fans/systemclock/whatever, Where can I find this information, or how do I begin looking for it? What's the name for what I'm trying to do, which is - Instruct the computer to record the value of a particular item, such as an axis on a joystick and how much it has moved in any particular direction, and whether or not a button has been pressed.

Next - Modular programming in C. I'm not quite sure how to handle that aspect. I've seen mention of functions such as exec, but an in-depth explanation is what I'm looking for. If nothing like that is available, then the names of what I'm trying to do would get me a long way. What is the name for the process of executing multiple other executables in sequential order? (Do the modules have to be compiled? I would assume that the "main" module would consist of statements to execute a program, then another, and each of the modules would do exactly what I programmed them to do, which includes storing variables, printing messages, and doing some math.)

System time, and the Hydrocarbon count (It's an emissions test program)
What's the actual C code to get system time, and assuming that the HydroCarbon sensor was a USB type of deal, how would I go about reading the value from it?

Furthermore, is there a way I could measure the voltage of a 1.5v battery by clever use of a soldering iron, and a USB extension? I mean, figure out a way to mate a 1.5v battery with a USB extension, plug that into a port on the tower, and read the voltage that way?



So, pseudo code as follows -

main
PROCESS Init
PROCESS Warmup
PROCESS Test
PROCESS Results


Init
RPM = 0
Abort = False
Avg = 0
NumReads = 0
TotalHC = 0
HC = 0
TimeRemaining = 0
StartTime = 0
RETURN

Warmup
WHILE RPM < 2500
READ RPM
WRITE RPM
ENDWHILE
RETURN

Test
StartTime = SystemClock (how do I actually get system time?)
ElapsedTime = 0
WHILE ElapsedTime < 90 OR Aborted = False
CurrentTime = SystemClock
ElapsedTime = CurrentTime - StartTime
READ HC (How do I actually get HC?)
TotalHC = TotalHC + HC
NumReads = NumReads + 1
TimeRemaining = 90 - ElapsedTime
WRITE "Time remaining:", TimeRemaining
READ RPM
WRITE RPM
IF RPM < 2500 OR RPM > 3600
Abort = True
WRITE "Due to sloppy throttle handling or less probable"
WRITE "circumstances, the test has been aborted."
ENDIF
ENDWHILE
RETURN


Results
IF Abort = False
Avg = TotalHC / NumReads
IF Avg < 220
WRITE "Pass"
ELSE
WRITE "Fail"
ENDIF
ENDIF
RETURN

Last edited by Dogs; 11-03-2009 at 05:24 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
codewarriorU.com C++ materials vivpad Programming 1 10-28-2009 04:28 AM
Advocacy Materials irvken Linux - General 1 07-13-2007 01:32 PM
materials for kernel programming masg Programming 1 01-11-2006 11:45 PM
Graphics materials Dark_Helmet Programming 5 08-20-2003 04:45 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration