LinuxQuestions.org
Visit Jeremy's Blog.
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 10-28-2005, 04:00 AM   #1
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Rep: Reputation: 15
??Good C References Please??


Hi again,

Does anyone know where I can find some good C references for the StdLib functions. I have found a couple including http://www.cplusplus.com/ref/ctime/ctime.html

The only problem is they almost seem to technical for me. Is there anything with easier readability because I would like to start learning the C functions programming is getting pretting boring without actually having the ability to learn these functions.

Books or anything as long as they explain in more detail.
 
Old 10-28-2005, 04:23 AM   #2
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
There a bunch of tutorials out there. I personally like:

http://www.cprogramming.com/

http://www.programmersheaven.com/

You might consider some books too. Sam Publications are usually a good first book. If you are just learning C for fun, then it's ok. Now, if you actually have a given application/dream in mind, you may be starting with an over-difficult language where the same could be accomplished in an easier, more enjoyable way

Regards!
 
Old 10-28-2005, 05:29 AM   #3
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
I can recommend K&R2 (`The C programming language, 2nd edition', Brian W. Kernighan & Dennis M. Ritchie).

If you need a quick reference to the functions ("you will be. You will be"):

Code:
# apt-get install manpages-dev
$ man malloc
hth --Jonas
 
Old 10-28-2005, 07:53 AM   #4
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Hi again,

Thanks for that. I have another question but it's more of a "need coding help" question.

Anyway here's my problem. I have a file that I want to read using a "stdlib.h" function and then change the data that it has read in. The file is below:

Code:
Accredited Funds: 4000
Funds Remaining: 400
The "Accredited Funds" and the "Funds Remaining" came from ouput in an earlier program using "fprintf();". Now what I would like to do is read in the "4000" and the "400" into two different variables and manipulate them according to what the user inputs. Is this possible? And if so how would I go about getting the "4000" and the "400" into two different variables? Can someone give me a small example please.


Thank You.
 
Old 10-28-2005, 08:00 AM   #5
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 46
man scanf

Code:
int x;
scanf("%d", &x);
 
Old 10-28-2005, 09:01 AM   #6
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by jonaskoelker
man scanf

Code:
int x;
scanf("%d", &x);
I don't quite understand what you mean by "scanf". At the least I thought it would be "fscanf();". Extra help appreciated thanks
 
Old 10-28-2005, 11:24 AM   #7
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
That's very basic. scanf is used to get input from the keyboard, while printf is used to output. C++ equivalents should be cout and cin. You might really consider a few tutorials, just to get you used with the syntax.

http://cplus.about.com/od/beginnerct.../aa032302b.htm

About fscanf and scanf, I've found this:

Quote:
For scanf, the C99 standard states "The fscanf function returns the value of
the macro EOF if an input failure occurs before any conversion." But glibc's
scanf does not respect conversions for which assignment was surpressed, even
though the standard states that the value is converted but not stored.
This is interesting too:
http://sources.redhat.com/ml/libc-al.../msg00117.html

So, I have three advices for you:

- First, do some tutorials for C or grab some books. You will need it.

- Second: I would try be to pick up a more modem language as C++ or Java. Those languages has a much clear syntax and it's easier to find tutorials about them all over the net. Good C tutorials are not as easy to find as it was before. Same goes to books. I found very difficult to find C programming books, whereas Java and C++ are all over the shelves.

- Third: Some scripting languages are extremely powerful, as python, and has an even cleaner syntax, while being still OOP and giving you full control how it works, even to pointers. Works with nearly every API out there, from gtk to OpenGL.

Regards!

Last edited by Mega Man X; 10-28-2005 at 11:26 AM.
 
Old 10-28-2005, 12:11 PM   #8
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Mega Man X
That's very basic. scanf is used to get input from the keyboard, while printf is used to output. C++ equivalents should be cout and cin. You might really consider a few tutorials, just to get you used with the syntax.

http://cplus.about.com/od/beginnerct.../aa032302b.htm

About fscanf and scanf, I've found this:



This is interesting too:
http://sources.redhat.com/ml/libc-al.../msg00117.html

So, I have three advices for you:

- First, do some tutorials for C or grab some books. You will need it.

- Second: I would try be to pick up a more modem language as C++ or Java. Those languages has a much clear syntax and it's easier to find tutorials about them all over the net. Good C tutorials are not as easy to find as it was before. Same goes to books. I found very difficult to find C programming books, whereas Java and C++ are all over the shelves.

- Third: Some scripting languages are extremely powerful, as python, and has an even cleaner syntax, while being still OOP and giving you full control how it works, even to pointers. Works with nearly every API out there, from gtk to OpenGL.

Regards!
I know exactly what "scanf" does and I know a bit about OOP. I do not want to use it to get input from the keyboard, I want to use a function to get input from a file. For example the below bit of info is my file... a text ASCII file:
Code:
Accredited Funds: 4000
Funds Remaining: 400
This file was made using a program who had two variables, "1.) Accredited Funds" and "2.) Funds Remaining".

The program did the math and wrote this info to the file, now I wish to "read" that info from the file and into another varialbe, so the "4000" will be stored in one variable and the "400" will be stored in the another variable; thus I will have two variables in my new program one of them containing the value "4000" and one of them containing the value "400" and the value in these variables would have came from "Accredited Funds" and "Funds Remaining" within my .txt file above.
 
Old 10-28-2005, 01:08 PM   #9
Mega Man X
Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 63
Now I understand . Sorry. In this case, you need to use fopen to open a file and when you done, fclose to close it. Take a look here:

http://vergil.chemistry.gatech.edu/r...torial/io.html
 
Old 10-28-2005, 01:45 PM   #10
InvisibleSniper
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Debian
Posts: 113

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Mega Man X
Now I understand . Sorry. In this case, you need to use fopen to open a file and when you done, fclose to close it. Take a look here:

http://vergil.chemistry.gatech.edu/r...torial/io.html
Yep, thanks for your help but I know this too. As I said I am trying to "read" into RAM the variables that's in the txt file. Preferably into the same variable (i.e "Accredited Funds" and "Funds Remaining"). Think of this file as being an .INI extension file.

I mean I want to use this file in exactly the same way as a normal program would use an .INI file. You know like whatever program that uses an .INI file will open the file, and edit it (this is what I want to do). But it treats certain settings within the file just as if it was a variable in memory(that being the program can change it's value). I don't want to "Append" text, I don't want to "Write" over any text, all I want to do is treat the two names I used in the file as variables. Accredited Funds one variable that holds a value in RAM and Funds Remaining that holds a value in RAM also.

Put very simply... as I am even starting to confuse myself, I want to change the numbers in the file but not write over anything else except the numbers.

Thanks For Ya Help
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
shell references nariman Linux - Newbie 3 02-25-2006 05:36 AM
Security references unSpawn Linux - Security 6 02-25-2006 01:04 AM
method references in perl mschutte Programming 4 04-26-2005 09:46 AM
references jenny_psion Programming 0 08-12-2003 03:06 AM
references to other other sites pbharris LQ Suggestions & Feedback 10 04-10-2002 10:20 AM


All times are GMT -5. The time now is 05:55 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration