473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C question...little OT

mdh
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Does anyone know how this convention started. Does the "s" stand for
"source" string, for example. Or is it as simple as s="string",
i="integer" and the next string would be t, u, v, etc.
Thanks

Jul 4 '07 #1
22 1432
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Does anyone know how this convention started. Does the "s" stand for
"source" string, for example.
I hope not, because that's not the source - it's the target!
Or is it as simple as s="string",
i="integer" and the next string would be t, u, v, etc.
Yeah, I think that's the most likely explanation. Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 4 '07 #2
mdh
....... two strings are given as *s and *t.
Does anyone know how this convention started. Does the "s" stand for
"source" string, for example.

I hope not, because that's not the source - it's the target!
Or is it as simple as s="string",
i="integer" and the next string would be t, u, v, etc.
RH wrote:
Yeah, I think that's the most likely explanation. Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.
tks Richard.

Jul 4 '07 #3
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
>mdh said:
>May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.
To wit, real gurus use one-letter names.
--
Roland Pibinger
"The best software is simple, elegant, and full of drama" - Grady Booch
Jul 4 '07 #4
Roland Pibinger said:
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
>>mdh said:
>>May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.
Only when it's obvious what they're for, as in this case.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 4 '07 #5
Roland Pibinger skrev:
To wit, real gurus use one-letter names.
As do mathematicians.
August
Jul 4 '07 #6
Roland Pibinger wrote:
>
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.
Which means that the standard's description of string.h
was written by gurus,
and that the standard's description of stdlib.h
was written by neophytes.

void *memset(void *s, int c, size_t n;

void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));

Either that, or your comment is silly.

--
pete
Jul 4 '07 #7
August Karlstrom <fu********@comhem.sewrites:
Roland Pibinger skrev:
>To wit, real gurus use one-letter names.

As do mathematicians.
Or, as they prefer to call themselves, m.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jul 4 '07 #8
In article <L-******************************@bt.com>, Richard Heathfield
<rj*@see.sig.invalidwrites
>Roland Pibinger said:
>On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
>>>mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.

Only when it's obvious what they're for, as in this case.
Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jul 4 '07 #9
mdh
On Jul 4, 1:54 pm, Chris Hills <c...@phaedsys.orgwrote:
>
Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)
oh..great!! That's all I need!!! :-)

Jul 4 '07 #10
In article <11**********************@e9g2000prf.googlegroups. com>, mdh
<md**@comcast.netwrites
>On Jul 4, 1:54 pm, Chris Hills <c...@phaedsys.orgwrote:
>>
Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)

oh..great!! That's all I need!!! :-)
Caveat: It was after mid-night in a restaurant and there was a lot of
beer about :-)

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jul 4 '07 #11
mdh wrote:
>
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Does anyone know how this convention started. Does the "s" stand for
"source" string, for example. Or is it as simple as s="string",
i="integer" and the next string would be t, u, v, etc.
They are just labels, and only valid within the function. There is
no special meaning. Change them if you like, you won't affect the
code (but maybe the debugging info).

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 5 '07 #12
Chris Hills wrote:
<md**@comcast.netwrites
>Chris Hills <c...@phaedsys.orgwrote:
>>Stroustrup once suggested that [now we have unicode] function
names should all be one character but have a different colour to
indicate their use. So you could have 256 functions called A() :-)

oh..great!! That's all I need!!! :-)

Caveat: It was after mid-night in a restaurant and there was a
lot of beer about :-)
Making programming unavailable to the color-blind. Whee.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jul 5 '07 #13
Chris Hills <ch***@phaedsys.orgwrites:
In article <L-******************************@bt.com>, Richard Heathfield
<rj*@see.sig.invalidwrites
Roland Pibinger said:
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.
Only when it's obvious what they're for, as in this case.

Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate their
use. So you could have 256 functions called A() :-)
http://www.colorforth.com/cf.html

Yours,

--
Jean-Marc
Jul 5 '07 #14

"Chris Hills" <ch***@phaedsys.orgha scritto nel messaggio news:XH**************@phaedsys.demon.co.uk...
In article <L-******************************@bt.com>, Richard Heathfield <rj*@see.sig.invalidwrites
>>Roland Pibinger said:
>>On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.

Only when it's obvious what they're for, as in this case.

Stroustrup once suggested that [now we have unicode] function names should all be one character but have a different colour to
indicate their use. So you could have 256 functions called A() :-)
In maths, you can't use several letters for a name (ab would mean
a times b), but there are plenty of capital letters, greek letters,
strange diacritics, subscripts etc. to have enough symbols. But I
once resorted to use a cyrillic l for a length when I was already
using L, l and a greek lambda in the problem.
Jul 5 '07 #15
Chris Hills <ch***@phaedsys.orgwrote:
In article <L-******************************@bt.com>, Richard Heathfield
<rj*@see.sig.invalidwrites
Roland Pibinger said:
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.
Only when it's obvious what they're for, as in this case.

Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)
I strongly doubt that. Stroustrup is not a fool (for all that he
designed C++ ;-) ) and he is certainly not stupid enough to confuse
character sets with colour.

Richard
Jul 6 '07 #16
In article <46*****************@news.xs4all.nl>, Richard Bos
<rl*@hoekstra-uitgeverij.nlwrites
>Chris Hills <ch***@phaedsys.orgwrote:
>In article <L-******************************@bt.com>, Richard Heathfield
<rj*@see.sig.invalidwrites
>Roland Pibinger said:

On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.

Only when it's obvious what they're for, as in this case.

Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)

I strongly doubt that.
I was there when he said it. However did you miss the caveat?
Stroustrup is not a fool (for all that he
designed C++ ;-) ) and he is certainly not stupid enough to confuse
character sets with colour.
You had to have been there really.

--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
/\/\/ ch***@phaedsys.org www.phaedsys.org \/\/\
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Jul 6 '07 #17
On Jul 6, 7:05 am, Chris Hills <c...@phaedsys.orgwrote:
>
>Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)
I strongly doubt that.

I was there when he said it. However did you miss the caveat?
Stroustrupis not a fool (for all that he
designed C++ ;-) ) and he is certainly not stupid enough to confuse
character sets with colour.

You had to have been there really.
B Stroustrup: Generalizing Overloading for C++2000. Overload, Issue
25. April 1, 1998. Note the date. http://www.research.att.com/~bs/whitespace98.pdf

-- Bjarne Stroustrup; http://www.research.att.com/~bs

Jul 6 '07 #18
On Wed, 04 Jul 2007 20:02:03 +0000, pete wrote:
Roland Pibinger wrote:
>>
On Wed, 04 Jul 2007 17:04:03 +0000, Richard Heathfield rote:
>mdh said:
May I ask something that has often puzzled me in C.
In K&R, for example (p106), in explaining their version of strcmp,
pointers to the two strings are given as *s and *t.
Certainly, when I
demonstrate strcpy, I use char *u = s to hold the return value.

To wit, real gurus use one-letter names.

Which means that the standard's description of string.h
was written by gurus,
and that the standard's description of stdlib.h
was written by neophytes.

void *memset(void *s, int c, size_t n;

void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));

Either that, or your comment is silly.
If you count how many vowels are used in function names in
string.h, and how many ones in stdlib.h, you might have some
insight of why they needed gurus for the former but normal people
sufficed for the latter.

--
Army1987
(Replace "NOSPAM" with "email")

Jul 6 '07 #19
bjarne wrote:
On Jul 6, 7:05 am, Chris Hills <c...@phaedsys.orgwrote:
>>>Stroustrup once suggested that [now we have unicode] function names
should all be one character but have a different colour to indicate
their use. So you could have 256 functions called A() :-)
I strongly doubt that.
I was there when he said it. However did you miss the caveat?
>>Stroustrupis not a fool (for all that he
designed C++ ;-) ) and he is certainly not stupid enough to confuse
character sets with colour.
You had to have been there really.

B Stroustrup: Generalizing Overloading for C++2000. Overload, Issue
25. April 1, 1998. Note the date. http://www.research.att.com/~bs/whitespace98.pdf

-- Bjarne Stroustrup; http://www.research.att.com/~bs
That made my day!

Jul 6 '07 #20
Army1987 wrote, On 06/07/07 20:08:
On Fri, 06 Jul 2007 12:19:03 -0400, David T. Ashley wrote:
<snip discussion about short names>
>It is the same for function parameters ... "s" and "t" are fine. It adds no
value to say "source" and "target".
Too bad that, in that prototype of strcpy(), s stood for target
and t stood for source.
No, s stands for "stick it 'ere" and t stands for "take it from 'ere".
You not learnt English proper? ;-)
>And even for a formal parameter that is more complex, I'd be more likely to
add a comment than to type the same long name over and over again. For
example:
Agreed. One is more likely to misspell representation than repr,
for example.
There is a balance to be struck, as in all things. How do I know "repr"
isn't the "reprisal" flag?
--
Flash Gordon
Not being serious, for once.
Jul 6 '07 #21
On Fri, 06 Jul 2007 21:33:55 +0100, Flash Gordon wrote:
Army1987 wrote, On 06/07/07 20:08:
>On Fri, 06 Jul 2007 12:19:03 -0400, David T. Ashley wrote:

<snip discussion about short names>
>>It is the same for function parameters ... "s" and "t" are fine. It adds no
value to say "source" and "target".
Too bad that, in that prototype of strcpy(), s stood for target
and t stood for source.

No, s stands for "stick it 'ere" and t stands for "take it from 'ere".
You not learnt English proper? ;-)
>>And even for a formal parameter that is more complex, I'd be more likely to
add a comment than to type the same long name over and over again. For
example:
Agreed. One is more likely to misspell representation than repr,
for example.

There is a balance to be struck, as in all things. How do I know "repr"
isn't the "reprisal" flag?
void printrepr(sometype *obj)
{
unsigned char[sizeof *obj]; /* representation */
...
}
or:
damage_t revenge(enemy_t *enemy, damage_t damage)
{
static int repr = 0; /* reprisal */
...
}
(But you'd need longer names if you plan to use both in the same
scope...)

--
Army1987
(Replace "NOSPAM" with "email")

Jul 7 '07 #22
bjarne <bj****@gmail.comwrote:
On Jul 6, 7:05 am, Chris Hills <c...@phaedsys.orgwrote:
>>Stroustrup once suggested that [now we have unicode] function names
>should all be one character but have a different colour to indicate
>their use. So you could have 256 functions called A() :-)
>I strongly doubt that.
I was there when he said it. However did you miss the caveat?
I didn't miss a caveat, because there was none. Neither did I miss the
smiley, but since smilies can mean anything from "he didn't mean that"
through "I didn't mean that" and "he did mean it and I thought it was
funny" to "this makes me happy", I could not draw any conclusion from
it.
>Stroustrupis not a fool (for all that he
>designed C++ ;-) ) and he is certainly not stupid enough to confuse
>character sets with colour.
You had to have been there really.

B Stroustrup: Generalizing Overloading for C++2000. Overload, Issue
25. April 1, 1998. Note the date.
This, however, is quite conclusive. ( :-) (fourth meaning))

Richard
Jul 10 '07 #23

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

Similar topics

18
by: Andre Laplume via AccessMonster.com | last post by:
I have inherited a bunch of dbs which are are shared among a small group in my dept. We typically use the dbs to write queries to extract data, usually dumping it into Excel. Most dbs originated...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
21
by: siroregano | last post by:
Hi Everyone- I'm new to this group, and almost-as-new to asking programming questions publicly, so please forgive me if I miss a convention or two! I have a text file, around 40,000 lines...
10
by: Tom Dacon | last post by:
I'm curious to see if anyone has an opinion on this little design question - I'm doing a computational astronomy library in C#, purely for my own use, and one of the things that happens regularly...
1
by: Natalia DeBow | last post by:
Hi, I am working on a Windows-based client-server application. I am involved in the development of the remote client modules. I am using asynchronous delegates to obtain information from...
6
by: rodchar | last post by:
Hey all, I'm trying to understand Master/Detail concepts in VB.NET. If I do a data adapter fill for both customer and orders from Northwind where should that dataset live? What client is...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
14
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
38
by: Till Crueger | last post by:
Hi, I stumbled upon the following code to determine byte ordering in the FAQ: union { int i; char c; } x; /* do stuff */
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.