Re: without loop printing 1 to n
- From: jaysome <jaysome@xxxxxxxxxxx>
- Date: Sat, 23 Dec 2006 01:26:18 -0800
On Fri, 22 Dec 2006 11:00:57 +0000, Richard Heathfield
<rjh@xxxxxxxxxxxxxxx> wrote:
Yahooooooooo said:
no gotos
no loops
how is it possbile.....
Method 1 of N:
#include <stdio.h>
int main(void)
{
puts("1 to n");
return 0;
}
Method N of N:
#include <stdio.h>
#include <assert.h>
void printrange(unsigned long low, unsigned long high)
The function name "printrange" has external linkage. As such, in order
to be strictly conforming to the C90 Standard, it must be significant
from any other external name in the first six characters. You're lucky
you didn't lose your temper and name it something like
"printfrigginrange" instead.
The latter name would, of course, collide with printf in the included
file <stdio.h>, and the result would be undefined behavior.
One convention to consider, in order to reduce the probablility of
this type of undefined behavior, is to have an underscore somwehere in
the second to sixth characters of your external name, especially if it
separates words.
As an example, consider this function prototype:
void printrange(unsigned long low, unsigned long high);
You can accomplish both of the tenets above by inserting a single
underscore after the fifth character of this function name, i.e.:
void print_range(unsigned long low, unsigned long high);
The big advantage is that someone in your audience doesn't have to
spend minutes or hours (or days or years or forever?) trying to figure
out if the author pronounced it: "PRiority INT RANGE" (the range of an
object of type int that represents a task priority); or "PRImary NT
RANGE" (The pasture where most computers still running Windows NT have
retired to); or "PRINTeR ANGE" (The angst you feel when you are
experiencing printer problems); and possibly others.
I've wasted a lot of time--no--authors have wasted a lot of my time,
by not using underscores in their names.
Have a Merry Christmas
--
jay
.
- Follow-Ups:
- Re: without loop printing 1 to n
- From: Richard Heathfield
- Re: without loop printing 1 to n
- References:
- without loop printing 1 to n
- From: Yahooooooooo
- Re: without loop printing 1 to n
- From: Richard Heathfield
- without loop printing 1 to n
- Prev by Date: Re: malloc for strings(beginner)
- Next by Date: Intializing Pointer Array
- Previous by thread: Re: without loop printing 1 to n
- Next by thread: Re: without loop printing 1 to n
- Index(es):
Relevant Pages
|