LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Programming in C Tutorial (https://www.linuxquestions.org/questions/programming-9/programming-in-c-tutorial-374099/)

Mercurius 10-17-2005 08:51 PM

Programming in C Tutorial
 
Hi guys, i've been skipping on and off from books about C Programming. I have K&R but they thins very very algorithmic, to much algorithmic for me. I have a hacker's guide to C programming written by lovepump but it's awfully incomplete. I really want to learn C, but the problem is I cant take any courses since nothing is available in my area. Any suggestions? All say K&R but they are very very algorithmic, has anyone noticed that?

P.S. What functions should I use to copy a file from my hdd and then rename it? Like a backup program that would take a vimrc and would copy it to a vimrc.back...

cyb0rg777 10-17-2005 09:58 PM

hello ,I am a newbie myself but I will try to help.

I like Herbert Shildt C the complete reference or C++ the complete reference.
just keep learning and practicing.
for renameing files I'm not sure what to use ,try google
you could just use a bash script or something.

primo 10-18-2005 12:19 AM

http://www.crasseux.com/books/ctutorial/
http://www.gnu.org/software/libc/man...ode/index.html

ludwig 10-18-2005 01:11 AM

My first langauge was C, and I taught myself the language using Stephen G. Kochan's book, "Programming in C" . However, I think that's since gone out of print and has now been updated to "Programming in ANSI C" (http://www.amazon.com/gp/product/067...torialmania-20). This book was a godsend for me -- my only background was in the areas of classical piano and French, and I did ALL the exercises (okay, maybe one or two slipped by). Kochan explains things in a very concise, complete, plain-English manner, without being overly technical. (Much to my surprise, I ended up getting a master's in CS and worked at Symantec for four years as a developer. However, I have since then awoken from the narcotic spell of Windoze, and am now completely rejuvenated by linux!)

charliew 10-18-2005 04:00 AM

I found the book from O'Reilly "Practical C Programming, Third Edition" an excellent book. Concise and easy to follow explanations with loads of examples. I too have also used Schildt in the past but now prefer the O'Reilly series. Hope this helps

coldAndUgly 10-18-2005 04:24 AM

The C Book is an excellent resource for learning how to program in C.

sys-fire 10-18-2005 07:03 AM

C course
 
If you are looking for a C tutorial, you might be interested in about.com. They offer some free tutorials on C/C++ programming. Check it out. Hope this is what you are looking for.

:Pengy:

Mercurius 10-18-2005 10:18 AM

The C Book is full of errors sadly. I had to correct a few programs so it would compile.

How do I use the gdb in order to watch line by line of what happens in the program? And I would also like to see it in asm. Is there a way?

jorge.vargas 10-18-2005 11:53 AM

You should know that each language has a purpose, for example to do a backupfile you will probably use a scripting language since C is too complicated for that, you should really use shell or perl or python. For example this is a little python funtion a made for that. it will create N backups, instead of overwritting the last backup.

Code:

import shutil
                       
def backUp(fileName):
        '''busca archivos `fileName`.bak* hasta que encuentre uno no existente y copia el archivo'''
        cont=0
        while os.path.exists(fileName + '.bak' + str(cont)):
                        cont = cont + 1
        shutil.copyfile(fileName,fileName + '.bak' + str(cont))
        print "Creating " + fileName + '.bak' + str(cont) + "..."

if all you need is to make a backup then the shutil.copyfile line is all you need and a main function. You can even just do it on bash with "cp"

Anyway in C, pure C, you will need to read the file pointer, create a second file pointer, copy everything in it and to the other file then close both. here is a link to some funtions. http://gd.tuwien.ac.at/languages/c/p...rown/c_075.htm

And in C it it's cross platform :) that's why my script is in python

hope that help.

Orkie 10-18-2005 12:12 PM

Quote:

Originally posted by cyb0rg777
I like Herbert Shildt C the complete reference or C++ the complete reference.
I can't comment on those since I've never read them but his 'C++ A Beginner's Guide' (ISBN: 0-07-219467-7 McGraw-Hill/Osborne) is quite good (it could probably take somebody from no C to C++ straight away).

geletine 10-18-2005 05:24 PM

funny enough i am using K&R, i am on 1.9 character arrays , ive done some of the excises in the book like reversing the order of the temperture chart.
i am hopeing its just a matter of practise with experimentation, looking at loads of source of programs that interest you.

To program well in c takes years of learning

primo 10-18-2005 10:44 PM

Quote:

Originally posted by geletine
To program well in c takes years of learning
To program well may take time, but C isn't really a hard language to learn.

Deitel/Deitel C/C++ is a very good book. It's plenty of exercises.

chrism01 10-19-2005 12:06 AM

I can recommend this http://www.amazon.com/exec/obidos/tg...36739?v=glance
for learning C.
Plenty of fully explained examples. 4 1/2 stars avg over 54 reviews...

ignasibuch 10-19-2005 02:41 AM

O'Reilly e-books
 
I just downloaded a package of O'Reilly's ebooks by bittorrent. There are a couple about C programming. I'm also interested in getting to it and Perl too.
Can get the .torrent here

geletine 10-19-2005 08:07 AM

"To program well may take time, but C isn't really a hard language to learn. "

sorry, i should of meant to programme in c something ie, kernal, computer game , fily systems etc..

From wikipedia about Linus Torvalds

"His interest in computers began with a Commodore VIC-20. After the VIC-20 he purchased a Sinclair QL which he modified extensively, especially its operating system. He programmed an assembler and a text editor for the QL, as well as a few games. "

I can imagine this was done over a few years, thats what i am really getting at when i mean its hard to program in c.


Minix has been mentioned as a influence to him...


All times are GMT -5. The time now is 08:25 AM.