Aswin Rajamannar wrote:
> I'm new to C programming. While working with files, they say we can open and
> read or edit files. I can't understand the whole shit. What files can we
> open? My friend says we can open  only text files lik .txt and read it and
> add contents to it. But in a book, i saw that we can open files with
> extension .c and work with them. I don't just want to mug up what the text
> book says and write it in exam and pass. Tell me what a file pointer points
> to and what is the big advantage working with files. At a moment, i thought
> of skipping this section and proceed, but i feel you could prove some help
> to me.
> Regards,
> Aswin

Please keep the language used on this list civil and professional.  You 
are interacting with professionals here.

Your friend is wrong.  A program can open, read, and modify any file 
that the OS lets it open, read, and modify.  In general, if you can do 
something with a file, any program you write can too.  IMO, there is no 
such thing as a text file.  It might be _displayed_ in readable 
_characters_, but the actual data is still just a bunch of 0's and 1's - 
in other words, binary.

A file pointer generally stores information about an open file.  Things 
such as the handle/pointer that is OS-specific (used during the actual 
function call to interface with the OS), current file position, cached 
data that hasn't been read/written yet, etc.  It varies greatly 
depending on the compiler and OS.

Why is file processing important?  Well, some people can get by not 
having to read files but pretty much everything is file-based on some 
level - even major database vendors like MySQL, Microsoft SQL Server, 
and Oracle have to store their data somewhere - and those database 
products are written in C/C++.


Whatever book you are reading is probably teaching you C/C++ 
incorrectly.  You should also be learning C++.

When you joined c-prog, you should have received an e-mail containing 
the group welcome message. In that message was a list of books that you 
should read. Just in case you missed the message, here is that list of 
books again and the order in which you should be reading them:

"Accelerated C++" by Koenig and Moo (ISBN #020170353X)
"Safe C++ Design Principles" by Thomas Hruska
"The C++ Standard Library" by Nicolai Josuttis (ISBN #0201379260)
"Effective C++" by Scott Meyers (ISBN #0201924889)
"More Effective C++" by Scott Meyers (ISBN #020163371X)

If you are learning or looking to learn C, consider learning C++ 
instead. It is much more versatile and offers powerful features that C 
doesn't offer. If you happen to be already reading something other than 
the books above, seriously consider supplementing or replacing your book 
with the above.

If you can't afford the books mentioned, Bruce Eckel offers "Thinking in 
C++" for free from his website:

http://mindview.net/Books/TICPP/ThinkingInCPP2e.html


And the group owner, Thomas Hruska, has generously donated his book 
"Safe C++ Design Principles" to c-prog group members for free:

http://tech.groups.yahoo.com/group/c-prog/files/Books/


Beware any C/C++ author who does not adhere closely to the ANSI C/C++ 
Standard. One very popular author is Yashavant Kanetkar who is the 
author of "Let Us C". His writing may be simple to understand however 
his code is non-ANSI Standard. Similar great writers have shown up over 
the years who tell wonderful stories but don't adhere to the Standards 
defined by the ANSI C/C++ committees.

You should also obtain at least copy of a draft copy of the ANSI C/C++ 
Standard. Draft copies are free and c-prog links to quite a few of them 
here:

http://tech.groups.yahoo.com/group/c-prog/links/Standards_001012496381/


-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to