Does anyone know where I can find a good online C programming test?
I used Google to search for
"C programming test"
and found lots of stuff but the first several pages were disappointing. 51 20045
On Mon, 2 Feb 2004, E. Robert Tisdale wrote: Does anyone know where I can find a good online C programming test?
________________
/| /| | | |
||__|| | | REMEMBER NOT |
/ O O\__ | TO FEED THE |
/ \ | TROLLS |
/ \ \|________________|
/ _ \ \ ||
/ |\____\ \ ||
/ | | | |\____/ ||
/ \|_|_|/ | _||
/ / \ |____| ||
/ | | | --|
| | | |____ --|
* _ | |_|_|_| | \-/
*-- _--\ _ \ | ||
/ _ \\ | / `
* / \_ /- | | |
* ___ c_c_c_C/ \C_c_c_c____________
"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in message
news:Pi***********************************@unix42. andrew.cmu.edu... On Mon, 2 Feb 2004, E. Robert Tisdale wrote: Does anyone know where I can find a good online C programming test?
________________ /| /| | | | ||__|| | | REMEMBER NOT | / O O\__ | TO FEED THE | / \ | TROLLS | / \ \|________________| / _ \ \ || / |\____\ \ || / | | | |\____/ || / \|_|_|/ | _|| / / \ |____| || / | | | --| | | | |____ --| * _ | |_|_|_| | \-/ *-- _--\ _ \ | || / _ \\ | / ` * / \_ /- | | | * ___ c_c_c_C/ \C_c_c_c____________
Ha-ha-ha!
"Vijay Kumar R Zanvar" <vi*****@hotpop.com> wrote in message
news:bv************@ID-203837.news.uni-berlin.de... "Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in message news:Pi***********************************@unix42. andrew.cmu.edu... On Mon, 2 Feb 2004, E. Robert Tisdale wrote: Does anyone know where I can find a good online C programming test?
________________ /| /| | | | ||__|| | | REMEMBER NOT | / O O\__ | TO FEED THE | / \ | TROLLS | / \ \|________________| / _ \ \ || / |\____\ \ || / | | | |\____/ || / \|_|_|/ | _|| / / \ |____| || / | | | --| | | | |____ --| * _ | |_|_|_| | \-/ *-- _--\ _ \ | || / _ \\ | / ` * / \_ /- | | | * ___ c_c_c_C/ \C_c_c_c____________
Ha-ha-ha!
Forgot to add. I think by [ERT], in the subject line, you mean [OT].
Vijay Kumar R Zanvar <vi*****@hotpop.com> scribbled the following: "Vijay Kumar R Zanvar" <vi*****@hotpop.com> wrote in message news:bv************@ID-203837.news.uni-berlin.de... "Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in message news:Pi***********************************@unix42. andrew.cmu.edu... > On Mon, 2 Feb 2004, E. Robert Tisdale wrote: > > Does anyone know where I can find a good online C programming test? > > ________________ > /| /| | | | > ||__|| | | REMEMBER NOT | > / O O\__ | TO FEED THE | > / \ | TROLLS | > / \ \|________________| > / _ \ \ || > / |\____\ \ || > / | | | |\____/ || > / \|_|_|/ | _|| > / / \ |____| || > / | | | --| > | | | |____ --| > * _ | |_|_|_| | \-/ > *-- _--\ _ \ | || > / _ \\ | / ` > * / \_ /- | | | > * ___ c_c_c_C/ \C_c_c_c____________
Ha-ha-ha! Forgot to add. I think by [ERT], in the subject line, you mean [OT].
I thought he meant E. Robert Tisdale. You know, ERT.
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I said 'play as you've never played before', not 'play as IF you've never
played before'!"
- Andy Capp
Vijay Kumar R Zanvar wrote:
.... snip ... Forgot to add. I think by [ERT], in the subject line, you mean [OT].
No he doesn't. You obviously have not done the requisite lurking
before posting.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
"CBFalconer" <cb********@yahoo.com> wrote in message
news:40***************@yahoo.com... Vijay Kumar R Zanvar wrote: ... snip ... Forgot to add. I think by [ERT], in the subject line, you mean [OT].
No he doesn't. You obviously have not done the requisite lurking before posting.
No wonder they say satire is dead... <g>
--
Peter
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:40**************@jpl.nasa.gov... Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions
are those of other posters. If I post code with errors, it gets
quickly torn to shreds -- which is a Good Thing(tm).
The additional benefit is that there are folks here willing to
*explain* what's wrong with poor or broken code.
-Mike
Mike Wahler wrote: "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:40**************@jpl.nasa.gov... Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters.
Mr Tisdale has, of course, already taken that test many times, and failed it
many times.
<snip>
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Mike Wahler wrote: E. Robert Tisdale wrote:
Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters. If I post code with errors, it gets quickly torn to shreds -- which is a Good Thing(tm).
The additional benefit is that there are folks here willing to *explain* what's wrong with poor or broken code.
I agree.
But it would be helpful if someone had collect these examples
into a handy compendium.
Richard Heathfield wrote: Mike Wahler wrote:
E. Robert Tisdale wrote:
Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters.
Mr. Tisdale has, of course, already taken that test many times and failed it many times.
You can find examples of my C code at http://www.netwood.net/~edwin/svmtl/
Just click on
The ANSI C Numerical Class Library
Please remind me where I can find examples of your C programs.
E. Robert Tisdale wrote: Richard Heathfield wrote:
Mike Wahler wrote:
E. Robert Tisdale wrote:
Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters. Mr. Tisdale has, of course, already taken that test many times and failed it many times.
You can find examples of my C code at
http://www.netwood.net/~edwin/svmtl/
Just click on
The ANSI C Numerical Class Library
I had a quick look. Approximately 6000 lines of code in various .c and .h
files. (3200 when blank lines and comments are removed.)
Most of it wouldn't compile under a conforming C90 implementation, because
of heavy use of the inline keyword, which doesn't exist in C90.
I didn't spend very long reading the code, because I found it to be almost
unreadable. Here's a quick extract, taken entirely at random:
ncl_dcsubmatrix* /* M -= N */
(ncl_dcsubm_msub)(ncl_dcsubmatrix* pM, const ncl_dcsubmatrix* pN) {
ncl_extent mM = ncl_dcsubm_extent2(pM);
ncl_offset i = 0;
#ifdef NCL_ERRANT
ncl_extent mN = ncl_dcsubm_extent2(pN);
if (mM != mN) {
ncl_message("In function ncl_dcsubm_msub(ncl_dcsubmatrix*,\n"
" const ncl_dcsubmatrix*): submatrix differ in second extent.\n");
mM = (mM < mN)? mM: mN;
}
#endif /* NCL_ERRANT */
for (i = 0; i < mM; ++i) {
ncl_dcsubvector v = ncl_dcsubm_subv2(pM, i);
ncl_dcsubvector u = ncl_dcsubm_subv2(pN, i);
ncl_dcsubv_vsub(&v, &u);
ncl_dcsubv_destroy(&u);
ncl_dcsubv_destroy(&v);
}
return pM; }
Frankly, I find that unreadable.
Please remind me where I can find examples of your C programs.
In the literature.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
In article <40**************@jpl.nasa.gov>,
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote: Richard Heathfield wrote:
Mike Wahler wrote:
E. Robert Tisdale wrote:
Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters.
Mr. Tisdale has, of course, already taken that test many times and failed it many times.
You can find examples of my C code at
http://www.netwood.net/~edwin/svmtl/
Just click on
The ANSI C Numerical Class Library
Please remind me where I can find examples of your C programs.
I am impressed.
That anyone would write that kind of code and willingly publish it where
everyone can see it...
Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@titan.btinternet.com>... Mike Wahler wrote:
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:40**************@jpl.nasa.gov... Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters.
Mr Tisdale has, of course, already taken that test many times, and failed it many times.
Yes, but others failed it many times as well, sometimes thanks to him,
e.g. when many C people stated that you could not return structs from
functions. I don't want to google, but it went something like this
struct foo f() {
struct foo s;
s.x = x;
s.y = y;
s.z = z;
return s;
}
*Many* (but not ERT) said you could not do this in C. So let's be fair
here.
MSG
"Richard Heathfield" <do******@address.co.uk.invalid> wrote in message
news:bv**********@sparta.btinternet.com... I didn't spend very long reading the code, because I found it to be almost unreadable. Here's a quick extract, taken entirely at random:
ncl_dcsubmatrix* /* M -= N */ (ncl_dcsubm_msub)(ncl_dcsubmatrix* pM, const ncl_dcsubmatrix* pN) { ncl_extent mM = ncl_dcsubm_extent2(pM); ncl_offset i = 0; #ifdef NCL_ERRANT ncl_extent mN = ncl_dcsubm_extent2(pN); if (mM != mN) { ncl_message("In function ncl_dcsubm_msub(ncl_dcsubmatrix*,\n" " const ncl_dcsubmatrix*): submatrix differ in second extent.\n"); mM = (mM < mN)? mM: mN; } #endif /* NCL_ERRANT */ for (i = 0; i < mM; ++i) { ncl_dcsubvector v = ncl_dcsubm_subv2(pM, i); ncl_dcsubvector u = ncl_dcsubm_subv2(pN, i); ncl_dcsubv_vsub(&v, &u); ncl_dcsubv_destroy(&u); ncl_dcsubv_destroy(&v); } return pM; }
Frankly, I find that unreadable.
Not wanting to defend Mr ERT, I must regretfully say that most GPL code I
have seen looks worse. Moreover it is usually highly non-portable. Is there
a clause in GPL that I missed that says that the source must be unreadable?
Peter
MSG wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@titan.btinternet.com>... Mike Wahler wrote:
> > "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message > news:40**************@jpl.nasa.gov... >> Does anyone know where I can find a good online C programming test? > > The best one I'm aware of is this newsgroup. The test questions > are those of other posters. Mr Tisdale has, of course, already taken that test many times, and failed it many times.
Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions.
Er, that's bizarre. Of course you can. The Standard even gives an example of
(a pointer to) a function that returns a struct.
Not saying it's a great idea, mind - but you can certainly do it.
I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C.
Do you have a thread reference for that? A message ID or something?
So let's be fair here.
I wasn't aware that I was being unfair. Anyone who says you can't return
structs from functions in C deserves a (metaphorical) slap on the wrist.
That doesn't change what I said about Tisdale, of course.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Christian Bau wrote: I am impressed.
That anyone would write that kind of code and willingly publish it where everyone can see it...
And exactly where can we download this code that *you* are so proud of?
Peter Pichler wrote:
<snip> I must regretfully say that most GPL code I have seen looks worse. Moreover it is usually highly non-portable. Is there a clause in GPL that I missed that says that the source must be unreadable?
No, but there does seem to be some kind of underlying ethos of "I'm doing
this for free, so I don't have to be legible", which I find appalling. I go
to a lot of trouble to make my own code readable. Whether I succeed is for
others to judge for themselves, but at least I try. I wish this were more
common.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
"MSG" <ms*****@yahoo.com> wrote: Yes, but others failed it many times as well, sometimes thanks to him
[ERT], e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
OK, let's be fair. The code above *is* in fact illegal ;-)
MSG wrote: struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
I don't believe you when you say "many said you could not do this in C."
I'd like to see you back that up.
Yes,it is true that Trollsdale is not a complete idiot, which makes him
dangerous. He can talk a good game, enough to suck the newbies in.
Brian Rodenborn
Peter Pichler wrote: "MSG" <ms*****@yahoo.com> wrote: Yes, but others failed it many times as well, sometimes thanks to him
[ERT], e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
OK, let's be fair. The code above *is* in fact illegal ;-)
Why?
$ cat foo.c
#include <stdio.h>
struct foo
{
int x;
int y;
int z;
};
int x, y, z;
/* Here's that code again, this time in some context. */
struct foo f() {
struct foo s;
s.x = x;
s.y = y;
s.z = z;
return s;
}
int main(void)
{
struct foo v;
x = 6;
y = 42;
z = 117;
v = f();
printf("%d\n%d\n%d\n", v.x, v.y, v.z);
return 0;
}
$ gcc -g -W -Wall -ansi -pedantic -o foo foo.c
$ ./foo
6
42
117
The fact that the code produces no diagnostics at a fairly severe warning
level, and gives the expected results, is of course not conclusive. But
neither is a simple assertion that the code is illegal!
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Richard Heathfield <do******@address.co.uk.invalid> spoke thus: struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
OK, let's be fair. The code above *is* in fact illegal ;-)
Why?
It may be that he was confused (as I recently was) about returning
automatic variables. The code is legal, but I had to delete words I
just wrote asserting the opposite - if it hadn't been one of
unimpeachable correctness such as yourself who had posted that, I
might have been lured into yet another stupid post ;)
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
On Wed, 4 Feb 2004, Richard Heathfield wrote: Peter Pichler wrote: "MSG" <ms*****@yahoo.com> wrote: Yes, but others failed it many times as well, sometimes thanks to him [ERT], e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z; return s; }
*Many* (but not ERT) said you could not do this in C. So let's be fair here. OK, let's be fair. The code above *is* in fact illegal ;-)
Why?
<snip> /* Here's that code again, this time in some context. */
Okay, *now* it's legal. ;-) [I can only assume that Peter was
referring to the fact that the OP had not defined 'struct foo'
anywhere in the translation unit under discussion.]
For reasons explained elsethread, I am firmly *against* returning
structs from functions, almost as firmly as I am against malloc
casting or using ALL_UPPER_CASE for anything other than macros --
but I have never claimed that the practice is illegal, and I don't
recall anyone else's doing so.
-Arthur
On Tue, 3 Feb 2004 21:32:55 -0500 (EST), "Arthur J. O'Dwyer"
<aj*@nospam.andrew.cmu.edu> wrote in comp.lang.c: On Wed, 4 Feb 2004, Richard Heathfield wrote: Peter Pichler wrote: "MSG" <ms*****@yahoo.com> wrote: > > Yes, but others failed it many times as well, sometimes thanks to him > [ERT], e.g. when many C people stated that you could not return > structs from functions. I don't want to google, but it went something > like this > > struct foo f() { > struct foo s; > s.x = x; > s.y = y; > s.z = z; > return s; > } > > *Many* (but not ERT) said you could not do this in C. So let's be fair > here.
OK, let's be fair. The code above *is* in fact illegal ;-)
Why?
<snip> /* Here's that code again, this time in some context. */
Okay, *now* it's legal. ;-) [I can only assume that Peter was referring to the fact that the OP had not defined 'struct foo' anywhere in the translation unit under discussion.]
For reasons explained elsethread, I am firmly *against* returning structs from functions, almost as firmly as I am against malloc
Why, may I ask? I don't do it often, but have no qualms about doing
it when it is efficient.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
On Wed, 4 Feb 2004, Jack Klein wrote: On Tue, 3 Feb 2004 21:32:55 -0500 (EST), "Arthur J. O'Dwyer" wrote: For reasons explained elsethread, I am firmly *against* returning structs from functions, almost as firmly as I am against malloc
Why, may I ask? I don't do it often, but have no qualms about doing it when it is efficient.
<Pi**********************************@unix45.andre w.cmu.edu>
and follow-ups give the 'elsethread' argument to which I referred.
Mostly, it's that returning structs is
- not transparent enough for my taste
- almost always easy to do another way, at least in my code
- not the way I first saw it done (K&R1 explicitly mentions that
you couldn't pass structs *to* functions in Ye Olde C, but I didn't
find any mention of *returning* structs, not that I looked very hard).
This is the real meat of my argument; I *said* it was religious! :)
-Arthur,
signing off
Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@hercules.btinternet.com>... MSG wrote:
Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@titan.btinternet.com>... Mike Wahler wrote:
> > "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message > news:40**************@jpl.nasa.gov... >> Does anyone know where I can find a good online C programming test? > > The best one I'm aware of is this newsgroup. The test questions > are those of other posters.
Mr Tisdale has, of course, already taken that test many times, and failed it many times.
Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions.
Er, that's bizarre. Of course you can. The Standard even gives an example of (a pointer to) a function that returns a struct.
Not saying it's a great idea, mind - but you can certainly do it.
I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C.
Do you have a thread reference for that? A message ID or something?
I can't find it, given the limited time I have and the fact that I do
not recall any rare "keywords" from that thread. However, take a look
at this bit of ERT wisdom (pay attention to comments in asm code) http://groups.google.com/groups?selm...40jpl.nasa.gov
which is not as good as what I wanted to find, but nevertheless.
I think ERT lacks some social skills, granted, who doesn't? But
branding him a troll is probably a fruit of groupthink.
MSG
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:40**************@jpl.nasa.gov... Mike Wahler wrote:
E. Robert Tisdale wrote:
Does anyone know where I can find a good online C programming test?
The best one I'm aware of is this newsgroup. The test questions are those of other posters. If I post code with errors, it gets quickly torn to shreds -- which is a Good Thing(tm).
The additional benefit is that there are folks here willing to *explain* what's wrong with poor or broken code.
I agree. But it would be helpful if someone had collect these examples into a handy compendium.
Well then, go right ahead. Or are you asking others to
do your work for you?
I do indeed have a collection of snippets garnered from clc
for my own learning and use, but it's only specific to *my*
interests, and isn't really very 'general' or 'wide-scope'.
-Mike
MSG wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@hercules.btinternet.com>... MSG wrote:
> Richard Heathfield <do******@address.co.uk.invalid> wrote in message > news:<bv**********@titan.btinternet.com>... >> Mike Wahler wrote: >> >> > >> > "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message >> > news:40**************@jpl.nasa.gov... >> >> Does anyone know where I can find a good online C programming test? >> > >> > The best one I'm aware of is this newsgroup. The test questions >> > are those of other posters. >> >> Mr Tisdale has, of course, already taken that test many times, and >> failed it many times. > > Yes, but others failed it many times as well, sometimes thanks to him, > e.g. when many C people stated that you could not return structs from > functions. Er, that's bizarre. Of course you can. The Standard even gives an example of (a pointer to) a function that returns a struct.
Not saying it's a great idea, mind - but you can certainly do it.
> I don't want to google, but it went something like this > > struct foo f() { > struct foo s; > s.x = x; > s.y = y; > s.z = z; > > return s; > } > > *Many* (but not ERT) said you could not do this in C.
Do you have a thread reference for that? A message ID or something?
I can't find it,
Neither can anyone else, it seems.
given the limited time I have and the fact that I do not recall any rare "keywords" from that thread. However, take a look at this bit of ERT wisdom (pay attention to comments in asm code)
http://groups.google.com/groups?selm...40jpl.nasa.gov
which is not as good as what I wanted to find, but nevertheless.
Nevertheless, it is an article in which Mr Tisdale demonstrates how one may
post off-topic articles on assembly language instead of giving an
appropriate answer based on the semantics of the C language.
I think ERT lacks some social skills, granted, who doesn't? But branding him a troll is probably a fruit of groupthink.
Do you? I think you just don't know him well enough. Of course, we must each
make up our own minds on these matters; but I think you're wasting your
time if you seek to persuade anyone who knows C that Mr Tisdale is worth
reading.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Jack Klein <ja*******@spamcop.net> scribbled the following: On Tue, 3 Feb 2004 21:32:55 -0500 (EST), "Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote in comp.lang.c: For reasons explained elsethread, I am firmly *against* returning structs from functions, almost as firmly as I am against malloc
Why, may I ask? I don't do it often, but have no qualms about doing it when it is efficient.
I would also be surprised if someone was against malloc. Erm, wait a
minute here...
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I wish someone we knew would die so we could leave them flowers."
- A 6-year-old girl, upon seeing flowers in a cemetery
In article <40**************@jpl.nasa.gov>,
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote: Christian Bau wrote:
I am impressed.
That anyone would write that kind of code and willingly publish it where everyone can see it...
And exactly where can we download this code that *you* are so proud of?
Tisdale, you are a complete idiot. You posted the address of my webpage
yourself...
If you want to run software that I have written, you might download some
Macintosh software from the Citrix webpage. No, they won't give you the
source code. http://download2.citrix.com/files/en...rrent/macICA_O
SX.dmg
Richard Heathfield wrote: MSG wrote: Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions.
Er, that's bizarre. Of course you can. The Standard even gives an example of (a pointer to) a function that returns a struct.
Further, a number of standard functions return structs (e.g. div()).
Jeremy.
Richard Heathfield wrote: MSG wrote:
I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C.
Do you have a thread reference for that? A message ID or something?
I think MSG had this post in mind: http://groups.google.com/gr*********...*@jpl.nasa.gov
Grumble <in*****@kma.eu.org> writes: Richard Heathfield wrote:
MSG wrote:
I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z; return s; }
*Many* (but not ERT) said you could not do this in C. Do you have a thread reference for that? A message ID or something?
I think MSG had this post in mind:
http://groups.google.com/gr*********...*@jpl.nasa.gov
If he had that thread in mind, his and my definition of the word "many"
are completely incompatible.
Martin
Richard Heathfield wrote: Peter Pichler wrote:
<snip>
I must regretfully say that most GPL code I have seen looks worse. Moreover it is usually highly non-portable. Is there a clause in GPL that I missed that says that the source must be unreadable?
No, but there does seem to be some kind of underlying ethos of "I'm doing this for free, so I don't have to be legible", which I find appalling. I go to a lot of trouble to make my own code readable. Whether I succeed is for others to judge for themselves, but at least I try. I wish this were more common.
For the benefit of the general public, many of us have found that
writing for clarity makes things easier for the reader down the
line, and further examination of that theme reveals that that
reader is us. Even so, later re-reading often produces much
scratching of various body parts.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Default User wrote:
.... snip ... Yes, it is true that Trollsdale is not a complete idiot, which makes him dangerous. He can talk a good game, enough to suck the newbies in.
This is no more dangerous than any other consumate idiot posting
here. However ERTs forte is revisionism, whereby he quotes
someone and edits that quote into meaninglessness or falsity.
This forces people to watch him closely, and deny those alleged
quotes. Idiocy is forgivable, the revisionism is not.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
In <Pi***********************************@unix47.andr ew.cmu.edu> "Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> writes: On Wed, 4 Feb 2004, Richard Heathfield wrote: Peter Pichler wrote: > "MSG" <ms*****@yahoo.com> wrote: >> >> Yes, but others failed it many times as well, sometimes thanks to him >> [ERT], e.g. when many C people stated that you could not return >> structs from functions. I don't want to google, but it went something >> like this >> >> struct foo f() { >> struct foo s; >> s.x = x; >> s.y = y; >> s.z = z; >> return s; >> } >> >> *Many* (but not ERT) said you could not do this in C. So let's be fair >> here. > > OK, let's be fair. The code above *is* in fact illegal ;-)
Why?
<snip> /* Here's that code again, this time in some context. */
Okay, *now* it's legal. ;-) [I can only assume that Peter was referring to the fact that the OP had not defined 'struct foo' anywhere in the translation unit under discussion.]
There was NO translation unit under discussion, merely a code snippet
that was NOT supposed to be a complete translation unit. People seldom
post complete translation units.
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Grumble wrote: Richard Heathfield wrote:
MSG wrote:
I don't want to google, but it went something like this
struct foo f() { struct foo s; s.x = x; s.y = y; s.z = z;
return s; }
*Many* (but not ERT) said you could not do this in C.
Do you have a thread reference for that? A message ID or something?
I think MSG had this post in mind:
http://groups.google.com/gr*********...*@jpl.nasa.gov
If that's the thread he had in mind, then "Many" appears to translate as
"Tom St Denis". Everyone else in the thread AFAICT gave appropriate and
correct answers (modulo Tisdale, on whose reply I make no comment either
way, since I didn't bother re-reading it).
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
"Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> wrote: On Wed, 4 Feb 2004, Richard Heathfield wrote: Peter Pichler wrote: "MSG" <ms*****@yahoo.com> wrote: > > struct foo f() { > struct foo s; > s.x = x; > s.y = y; > s.z = z; > return s; > } > > *Many* (but not ERT) said you could not do this in C. So let's be
fair> here.
OK, let's be fair. The code above *is* in fact illegal ;-) Why? <snip> /* Here's that code again, this time in some context. */
Okay, *now* it's legal. ;-) [I can only assume that Peter was referring to the fact that the OP had not defined 'struct foo' anywhere in the translation unit under discussion.]
Bingo! Plus missing declarations for x, y and z. And yes, I knew it was a
code fragment that would make sense in context, hence my smiley.
For reasons explained elsethread, I am firmly *against* returning structs from functions, [...]
I am not strictly against, but I don't do it myself.
Peter
In article <news:Pi***********************************@unix47 .andrew.cmu.edu>
Arthur J. O'Dwyer <aj*@nospam.andrew.cmu.edu> writes: Mostly, it's that returning structs is - not transparent enough for my taste - almost always easy to do another way, at least in my code - not the way I first saw it done (K&R1 explicitly mentions that you couldn't pass structs *to* functions in Ye Olde C, but I didn't find any mention of *returning* structs, not that I looked very hard). This is the real meat of my argument; I *said* it was religious! :)
It might be worth noting that the Portable C Compiler (one of
several common compilers, and perhaps even the most common,
implementing C at the time the K&R "white book" came out)
handled struct-value returns with non-reentrant code.
Specifically, it rewrote:
struct S f(...) { ... return val; }
...
result = f(...);
as:
struct S *f(...) {
static struct S retval;
...
retval = val;
return &retval;
}
result = *f(...);
(the ellipses here are neither K&R-1 C nor ANSI C, but rather
meant to imply "actual arguments do not matter").
The hidden-pointer-parameter method that gcc uses on the i386 is
"better", in my opinion, in that it is reentrant and can often
avoid some copying. It does, however, require that a declaration
of f() be in scope even if the caller intends to ignore the return
value. (Returning small structures in registers is even better
yet, of course, but often incompatible with vendor ABIs.)
--
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.
Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@hercules.btinternet.com>... Do you have a thread reference for that? A message ID or something? I can't find it,
Neither can anyone else, it seems.
Calling me a liar, heh? Very smooth.
BTW, many == 3 in this case:
Tom wrote "not valid"
Jarno (agreed?)
Nick implied that returning automatically allocated structs was
undefined
Not bad for an "idiot troll" given the limited time I have and the fact that I do not recall any rare "keywords" from that thread. However, take a look at this bit of ERT wisdom (pay attention to comments in asm code)
http://groups.google.com/groups?selm...40jpl.nasa.gov
which is not as good as what I wanted to find, but nevertheless.
Nevertheless, it is an article in which Mr Tisdale demonstrates how one may post off-topic articles on assembly language instead of giving an appropriate answer based on the semantics of the C language.
I think ERT lacks some social skills, granted, who doesn't? But branding him a troll is probably a fruit of groupthink.
Do you? I think you just don't know him well enough.
Even better! Think of me as a juror, not his defense attourney - I
think he's fit to represent himself. So far, I haven't seen the
"prosecution" try to make a case - all I saw was a bunch of emotional
people with old grudges. If you think *you* have a case, make it once,
say, post 3 links/msg-id's that conclusively show him to be a troll.
Of course, we must each make up our own minds on these matters; but I think you're wasting your time if you seek to persuade anyone who knows C that Mr Tisdale is worth
^^^^^^^^^^^^^^^^^^ reading.
It must be one of those "true Irishman" arguments.
BTW, anyone who "knows C" would only find "off-topic" messages
interesting here.
On 5 Feb 2004, MSG wrote: Neither can anyone else, it seems.
Calling me a liar, heh? Very smooth.
BTW, many == 3 in this case: Tom wrote "not valid" Jarno (agreed?)
Minus one: I pointed out that the local variable is inaccessible so
the reasoning doesn't apply.
MSG wrote: Richard Heathfield <do******@address.co.uk.invalid> wrote in message news:<bv**********@hercules.btinternet.com>...
>> >> Do you have a thread reference for that? A message ID or something? > > I can't find it, Neither can anyone else, it seems.
Calling me a liar, heh? Very smooth.
No, I wasn't. If I think you're lying, I'll say so. I didn't think you were
lying. I did consider the possibility that you were mistaken.
BTW, many == 3 in this case:
Less than half, then. When it's as few as 3, and also less than half the
field, I think I'd baulk at using "many".
<snip> > I think ERT lacks some social skills, granted, who doesn't? But > branding him a troll is probably a fruit of groupthink.
Do you? I think you just don't know him well enough.
Even better! Think of me as a juror, not his defense attourney - I think he's fit to represent himself.
Whatever. Those of us who've been here for a while reached our conclusions
long ago. Like I said - you just don't know him well enough yet. But you
will, you will.
<snip>
BTW, anyone who "knows C" would only find "off-topic" messages interesting here.
I quite enjoy (and am therefore quite interested in) helping other people to
learn about C. I don't find off-topic messages particularly interesting. So
either your argument is wrong /or/ I don't know C (or, conceivably, both).
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Something that calls itself MSG wrote: Richard Heathfield wrote:
Mr Tisdale has, of course, already taken that test many times and failed it many times. Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this:
struct foo f(void) { struct foo s; s.x = x; s.y = y; s.z = z; return s; }
Actually, it was something like this:
struct x x_create(int a, int b) {
struct x result;
result.a = a;
result.b = b;
return result;
}
Your example is seriously flawed.
Either you are an incompetent C programmer
or your example was a "test" of subscribers' C programming skills.
My guess is that the former (and not the latter) is correct.
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
1. obvious troll handle: MSG
2. disposable email address: yahoo.com
3. contentious subject: test failure
designed to provoke an emotional response
4. doesn't participate or take a position
in the discussion (remains "aloof").
Please learn to recognize (and ignore) trolls.
Jarno A Wuolijoki wrote: On 5 Feb 2004, MSG wrote: BTW, many == 3 in this case: Tom wrote "not valid" Jarno (agreed?)
Minus one: I pointed out that the local variable is inaccessible so the reasoning doesn't apply.
Whereupon Tom (St. Denis), realizing his think-o, withdrew
his original assertion. Nick implied that returning automatically allocated structs was undefined
Nick (Landsberg) was responding to something else entirely
in a later post, in which Mr. Tisdale claimed: You really need to appreciate the *magic* of a good optimizing C compiler here.
[snip code]
In fact, using my GNU C compiler, I can define
struct x* x_create(struct x*, int, int);
as an external function in another file then declare
extern struct x x_create(int a, int b);
Mr. Landsberg stated (fairly explicitly) that using this
would lead to undefined behavior.
So in the end, it appears that many == 0.
What was your point again?
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<40**************@jpl.nasa.gov>... Something that calls itself MSG wrote:
Richard Heathfield wrote:
Mr Tisdale has, of course, already taken that test many times and failed it many times.
Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this:
struct foo f(void) { struct foo s; s.x = x; s.y = y; s.z = z; return s; }
Actually, it was something like this:
struct x x_create(int a, int b) { struct x result; result.a = a; result.b = b; return result; }
Your example is seriously flawed. Either you are an incompetent C programmer or your example was a "test" of subscribers' C programming skills. My guess is that the former (and not the latter) is correct.
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
1. obvious troll handle: MSG 2. disposable email address: yahoo.com 3. contentious subject: test failure designed to provoke an emotional response 4. doesn't participate or take a position in the discussion (remains "aloof").
Please learn to recognize (and ignore) trolls.
Dear Sir,
Thank you very much for the timely troll alert, and please accept my
most sincere apologies for all of my misdeads. There is absolutely no
excuse, and I accept full responsibility for my actions and their
consequences. I would like to assure you that I will do my best to
avoid hurting your or anyone's feelings in the future.
Sincerely,
MSG
MSG wrote: "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<40**************@jpl.nasa.gov>... Something that calls itself MSG wrote:
<snip> Your example is seriously flawed. Either you are an incompetent C programmer or your example was a "test" of subscribers' C programming skills. My guess is that the former (and not the latter) is correct.
> *Many* (but not ERT) said you could not do this in C. > So let's be fair here.
1. obvious troll handle: MSG 2. disposable email address: yahoo.com 3. contentious subject: test failure designed to provoke an emotional response 4. doesn't participate or take a position in the discussion (remains "aloof").
Please learn to recognize (and ignore) trolls.
Dear Sir,
Thank you very much for the timely troll alert, and please accept my most sincere apologies for all of my misdeads.
What misdeeds? All you did was try to stick up for ERT - and look how he
treats you in return! But fear not - you are in rather good company.
Several clueful regular contributors to this newsgroup have been called
trolls by ERT. It's his substitute for technical argument.
--
Richard Heathfield : bi****@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
Richard Heathfield <do******@address.co.uk.invalid> scribbled the following: MSG wrote: "E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<40**************@jpl.nasa.gov>... Something that calls itself MSG wrote: <snip> Your example is seriously flawed. Either you are an incompetent C programmer or your example was a "test" of subscribers' C programming skills. My guess is that the former (and not the latter) is correct.
> *Many* (but not ERT) said you could not do this in C. > So let's be fair here.
1. obvious troll handle: MSG 2. disposable email address: yahoo.com 3. contentious subject: test failure designed to provoke an emotional response 4. doesn't participate or take a position in the discussion (remains "aloof").
Please learn to recognize (and ignore) trolls. Dear Sir,
Thank you very much for the timely troll alert, and please accept my most sincere apologies for all of my misdeads.
What misdeeds? All you did was try to stick up for ERT - and look how he treats you in return! But fear not - you are in rather good company. Several clueful regular contributors to this newsgroup have been called trolls by ERT. It's his substitute for technical argument.
Hey! No fair! Trollsdale hasn't called *me* a troll yet! Come on,
Trollsdale! Call me a troll! I'm using an obvious troll handle (my
real name), a disposable e-mail address (.helsinki.fi) and everything!
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Nothing lasts forever - so why not destroy it now?"
- Quake
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<40**************@jpl.nasa.gov>... Something that calls itself MSG wrote:
Richard Heathfield wrote:
Mr Tisdale has, of course, already taken that test many times and failed it many times. Yes, but others failed it many times as well, sometimes thanks to him, e.g. when many C people stated that you could not return structs from functions. I don't want to google, but it went something like this:
struct foo f(void) { struct foo s; s.x = x; s.y = y; s.z = z; return s; }
If x,y and z are global variables accessible at that point in the
program, there is absolutely no reason why this is flawed. Actually, it was something like this:
struct x x_create(int a, int b) { struct x result; result.a = a; result.b = b; return result; }
Your example is seriously flawed. Either you are an incompetent C programmer or your example was a "test" of subscribers' C programming skills. My guess is that the former (and not the latter) is correct.
*Many* (but not ERT) said you could not do this in C. So let's be fair here.
1. obvious troll handle: MSG 2. disposable email address: yahoo.com 3. contentious subject: test failure designed to provoke an emotional response 4. doesn't participate or take a position in the discussion (remains "aloof").
Please learn to recognize (and ignore) trolls.
"Peter Pichler" <pi*****@pobox.sk> wrote in message news:<4020324b_1@mk-nntp- Not wanting to defend Mr ERT, I must regretfully say that most GPL code I have seen looks worse. Moreover it is usually highly non-portable. Is there a clause in GPL that I missed that says that the source must be unreadable?
Peter
Ah, I'm relieved to hear it's not just me. I _though_ C didn't have to
look like that.
Do you have any good counterexamples? I'd like to take a look at some
real quality C code someday.
Harald Korneliussen wrote: "Peter Pichler" <pi*****@pobox.sk> wrote
Not wanting to defend Mr ERT, I must regretfully say that most GPL code I have seen looks worse. Moreover it is usually highly non-portable. Is there a clause in GPL that I missed that says that the source must be unreadable?
Ah, I'm relieved to hear it's not just me. I _though_ C didn't have to look like that.
Do you have any good counterexamples? I'd like to take a look at some real quality C code someday.
do {
Pick any regular here who publishes a URL.
Look for code published under GPL etc.
Evaluate portability and clarity for yourself.
} while not satisfied.
Most of us take pride in those characteristics.
--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: vpd |
last post by:
hi,
I want some help in organising an online programming contest. Is there
a ready made solution available in PHP or even Perl which I could use?
The contest is supposed to be based on C...
|
by: Varun |
last post by:
Hi Friends,
Department of Information Technology, Madras Institute of Technology,
Anna University, India
is conducting a technical symposium, Samhita. As a part of samhita, an
Online Programming...
|
by: Sridhar |
last post by:
Hi,
We, the students of CEG, Anna University are organizing an online
programming contest as part of aBaCus 2005. The contest itself
will start on 6th March 2005 at 1:00 pm IST and will end...
|
by: Sridhar |
last post by:
Hi,
We, the students of CEG, Anna University are organizing an online
programming contest as part of aBaCus 2005. The contest itself
will start on 6th March 2005 at 1:00 pm IST and will end...
|
by: pravink |
last post by:
Hi all,
I am interested in knowing any periodic (montly/weekly) programming
challeages held on internet...Does anybody know about such sites? Focus
should be on algorithm development and...
|
by: aarklon |
last post by:
Hi folks ,
Online C test at:
http://www.testyourabilities.com/webui/TestDesktop/Screens/Test.aspx
|
by: Romram |
last post by:
BITWISE is an annual online programming contest. The contest is
organized by the Computer Science and Engineering Department Society of
IIT Kharagpur, on the second Sunday of February every year....
|
by: Turbo |
last post by:
Please ignore if you are not interested in programming contests.
IIIT Hyderabad invites you to our annual Online Programming Contest
CodeCraft 2007. This is the 5th year of Codecraft. It has...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |