|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#16
|
||||||
|
||||||
|
Quote:
I spent about 6 hours on this process, the only hurdle was the question: "is the next line blank" Perhaps my perspective is off, and such a question does require extensive amounts of time, and a mere 6 hours is nothing compared to what I should have put in. But based on the commonality such a question must surely possess, I strongly suspect this is not the case. Quote:
Quote:
Quote:
So I am sorry that my dislike for C puts you off, and I am sorry that you have gotten the impression that I am lazy, just know that I do thoroughly enjoy the concepts behind the code, and that my motivation is not hindered my that dislike. |
|
#17
|
||||
|
||||
|
Documentation is all over the web (and not hard to find). A decent compiler usually has it also.
If you would read the documentation for fgets you would discover that a newline, if present, is always at the end. Consequently, if you remove all \r and \n from the end of the string, and the string is then of zero length, you have a blank line. There is little penalty in modern systems for using single-character reads, such as you attempted, simply because most modern systems read and cache the entire file (or as much as they can). In a lesser system such actions would incur a horrible penalty because file operations are orders of magnitude slower than memory accesses. Tossing in seeks (particularly one- or two-character movements) where they are absolutely unnecessary is also a questionable decision. There are algorithms and there are languages and there are the systems. With enough abstraction one can forget about the systems, but one will never be an optimal user if one does so.
__________________
C/C++ pointers (Original in the "Commonly Asked Questions" thread). |
|
#18
|
|||
|
|||
|
Quote:
At one time I had found a wonderful site that had example code using each library function, but I did not bookmark it because I did not realize the rarity and utility of the site (I've since searched for it probably ten different times to no avail). I would also absolutely love to see how the library functions are written. I've rewritten a few when I was unable to locate errors in my code and could not rule out the functions, it would be nice to compare them, as well as to learn. I'm particularly curious how the printf function works because I want to figure out how to dynamically send different numbers of variables to the function. I use gcc on Ubuntu, is there a suggested method to check if it documents these functions (I'm rather new to linux as well). Anyway, I appreciate the help in this thread, if I need to continue using C, I'll try to locate an in depth explanation of how files and file pointers work (if I can find the code for the functions that deal with this, I'll dissect that as well) |
|
#19
|
||||
|
||||
|
I don't know Ubuntu. I suspect, like most distros, it incorporates a manual called the "man pages". From the command-line type "man fopen", "man fgets", etc. You might even try "man man."
|
|
#20
|
||||
|
||||
|
Quote:
I cannot believe that you suggested that C is not well documented! It has an ISO standard that defines it. Note that the standard library and the language itself are different things. So you need to be clear which you are referring when asking for documentation. www.cplusplus.com has a comprehensive and detailed description of the C library. Don't be put off by the fact that it is C++ oriented. The only thing you need to be aware of is that in C++, C library headers have no extension and are prefixed with 'c', so <cstdio> should be replaced with <stdio.h> for example. In fact all the examples use the C form, which is also valid but deprecated in C++. I believe all the C library examples are purely C code and use no C++ specific syntax. Another reasonably good library reference is www.cppreference.com. It is less user friendly perhaps that cplusplus.com, but fills some gaps perhaps. Again don't be put off by teh name, it covers the C library (which is a subset of the C++ library - if you did not know that then that may explain why you had trouble finding documentation). A most comprehensive and up-to-date, but perhaps less user friendly library reference is www.dinkumware.com friendly. In the end C is not a big language, and is not well served by a big reference. You would do well to get yourself a copy of "The C Programming Language" by Kernighan and Ritchie (often referred to as just K&R). Documentation on both the language and the libraries can be found at http://publications.gbdirect.co.uk/c_book/. There are other tutorial resources you might consider listed at http://en.wikipedia.org/wiki/C_(pro...uage)#Tutorials . Clifford |
|
#21
|
||||
|
||||
|
Quote:
Actually since Ubuntu is designed for users first, rather than programmers, it only installs part of the man pages by default. For programming, you'll need to install the following packages: manpages-dev manpages-posix manpages-posix-dev You can do this by using the Synaptics package manager or going to the command line and typing: sudo apt-get install manpages-dev and do the same thing for the other two packages.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > ANSI C: Checking for a blank line in an input file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|