473,473 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C examples...?

jwl
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?

Thanks for your time
jwl
Nov 14 '05 #1
8 1502
jwl wrote:
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?

Thanks for your time
jwl


Thou all the gurus in this NG will probably contradict me the majority
of the code you say non-standard are standard as long as the compile
witout errors. If you have doubts compile them wit the ansi option
(e.g. "gcc -ansi ....") and you'll find where they fail.

Ciao
Giovanni
--
A computer is like an air conditioner,
it stops working when you open Windows.
Registered Linux user #337974 <http://counter.li.org/>

Nov 14 '05 #2
jwl said the following, on 12/25/04 10:31:
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?


One source you might want to have a look at is P.J. Plauger's excellent
book, _The Standard C Library_. It discusses what the standard requires
of the library, and contains an implementation of the library, which is
in portable C to the extent possible. Mosy important for learning, it
contains a discussion of *why* things are done.
--
Rich Gibbs
rg****@alumni.princeton.edu

Nov 14 '05 #3
"jwl" <jw*@nospam.net> wrote

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?

Look up GNU.

I don't think your strategy is going to be very productive, however. A lot
of real code is difficult to read, unless it is deliberately written for the
purpose of instructing beginners.

Also,a large number of real world programs use some non-standard library
calls. The facitilites provided by stdlib are very limited, for instance it
is not possible to list files in a directory, query the state of the
keyboard, or use any type of graphics including writing characters to set
locations on the screen.
Nov 14 '05 #4


jwl wrote:
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?


Take a look at the snippets collection which is online. Most of
the code is Standard C and compatible with any os. It
identifies the code that is os specific.

The link:
http://c.snippets.org/browser.php

--
Al Bowers
Tampa, Fl USA
mailto: xa******@myrapidsys.com (remove the x to send email)
http://www.geocities.com/abowers822/

Nov 14 '05 #5

On Sat, 25 Dec 2004, jwl wrote:

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?


http://www.contrib.andrew.cmu.edu/~ajo/
http://www.contrib.andrew.cmu.edu/~ajo/free-software/

If you find anything non-standard there, that isn't marked as such, with
the exception that I use 'is*(k)' instead of 'is*((unsigned char)k)' in
some programs, let me know at once! ;)

Richard Heathfield keeps a collection of C snippets, too, which
certainly ought to be portable (right?), but I won't vouch for that.
And I know that a lot of other clc regulars past and present have at
least one portable C library that they like to plug off and on. So
those might be decent starting places.

HTH,
-Arthur
Nov 14 '05 #6
Giovanni wrote:
jwl wrote:
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?

Thanks for your time
jwl

Thou all the gurus in this NG will probably contradict me the majority
of the code you say non-standard are standard as long as the compile
witout errors.


Not so. Firstly, the Standard doesn't define compiler "errors" as such.
Instead, it talks about diagnostics. Secondly and more importantly,
code that compiles doesn't necessarily mean code that works. Consider
the following code:

#include <stdio.h>

void foo(int *m, int *n)
{
*m = *n++; /* Danger! */
}

int main(void)
{
int i = 42;
foo(&i, &i);
printf("%d\n", i); /* what does this print? */
return 0;
}

is non-standard in the sense that the Standard does not define
its behaviour, but it will typically not generate an error.

If you have doubts compile them wit the ansi option
(e.g. "gcc -ansi ....") and you'll find where they fail.


Insufficient.
Nov 14 '05 #7
jwl wrote:
Hi everyone

I learn best by example so I'd like to find C source code to study,
especially stuff showing how to use the standard library. The trouble is,
although I can find tons of non-standard code, I can't find any strictly
ISO C code. Does anyone know a link to some interesting programs in
standard C?


Search the archives for this newsgroup (I think Google is perhaps still
just about usable); you will find plenty of sample source code not only
presented, but also dissected and improved.
Nov 14 '05 #8
In article <cq**********@titan.btinternet.com>
infobahn <in******@btinternet.com> wrote:
... the Standard doesn't define compiler "errors" as such.
Instead, it talks about diagnostics. Secondly and more importantly,
code that compiles doesn't necessarily mean code that works.
Right.
Consider the following code:

#include <stdio.h>

void foo(int *m, int *n)
{
*m = *n++; /* Danger! */
I think you meant to write:

*m = (*n)++;

As it is, since the postfix "++" binds more tightly than the prefix
"*", the expression means "increment n, and use the value it had
before said incrementation as the operand of unary-star."
}

int main(void)
{
int i = 42;
foo(&i, &i);
printf("%d\n", i); /* what does this print? */
return 0;
}

is non-standard in the sense that the Standard does not define
its behaviour, but it will typically not generate an error.


Given the corrected (or "adjusted to be in-correct"? :-) ) version
of function foo(), indeed. No diagnostic is required, and in order
to produce one, a compiler would have to deduce that *m and *n
both refer to the same underlying object (the "i" in main), thus
notice that the line in foo therefore has the undefined effect of
"i = i++", *and* be coded to complain about that. Even the latter
is all too rare, and the former requires extensive alias analysis,
which -- while easy enough in computing theory -- is rare for
practical reasons (it tends to take a lot of compile-time CPU
power for little code-improvement).
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Nov 14 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Guettler | last post by:
Hi! I read "How Python is developed" (comp.lang.python.announce), and think that there could be more examples in the docs. One think I really like to see: An example with mycmp(a, b)... in...
1
by: Ron Kneusel | last post by:
I have installed VTK 4.2.6 and Python 2.3.4. Both are working and I can run the VTK Python examples except for those in the GUI directory. These always fail with messages similar to this: ...
14
by: Jim Hubbard | last post by:
I am looking for documentation and code examples on DDML (Display Driver Management Level). It is mentioned in the 2000, XP and 2003 DDKs - but just barely. It has to do with mirroring a...
2
by: Rory Plaire | last post by:
Hi, I've been working with the J# browser control. I understand that v1.1b is scriptable, but can't find any examples on how to do this. Can someone point me in the right direction? thanks,...
1
by: sam++ | last post by:
Hi, I cd into examples/DLL/ and type "make", it failed to compile the example. The error is: # make make - -f DLL_Today.bor all make: don't know how to make all. Stop *** Error code 2 ...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
102
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality...
4
by: Michael | last post by:
Hi! (OK, slightly silly subject line :) I'm extremely pleased to say - Kamaelia 0.4.0 has been released! What's New & Changed? =====================
1
by: AppleBag | last post by:
Hello I have found examples of using an .mdb file in VS2K3, but apparently the components in the toolbox are different than the ones shown in the 2K3 examples. I have google'd and searched high...
10
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.