473,472 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

(Info) Test Your C Programming Strengths

Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...

Thank You

Regards
Kishor
Nov 14 '05 #1
34 14968
Kishor <na***********@rediffmail.com> spoke thus:
Click here : (url removed) to Test Your C Programming


Hm, let me try a few of those printf questions:

[Q001] - Undefined behavior, since main() must return an int.
[Q002] - Undefined behavior, since main() must return an int.
[Q003] - Undefined behavior, since main() must return an int.
[Q004] - Undefined behavior, since main() must return an int.
[Q005] - Undefined behavior, since main() must return an int.
[Q006] - Undefined behavior, since main() must return an int.

Oh well, this is getting boring. Back to work.

--
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.
Nov 14 '05 #2
na***********@rediffmail.com (Kishor) wrote:
Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.


What is this, a test on how many errors you can find on the site? Sorry,
I gave up after I ran out of fingers.

Richard
Nov 14 '05 #3
Kishor wrote:

Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...


Anyone who asserts that

"Also, this [C] is the ONLY language which has survived
in the computing world."

is clearly not a smart guy. I looked no further.

(ObPuzzle: Find *two* errors in the quoted sentence.)

--
Er*********@sun.com
Nov 14 '05 #4
Kishor wrote:
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...


Please learn the language before attempting to teach it. Thank you.

--
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
Nov 14 '05 #5
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
na***********@rediffmail.com (Kishor) wrote:
Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.


What is this, a test on how many errors you can find on the site? Sorry,
I gave up after I ran out of fingers.


I'm not surprised that there were that many errors; I'm just surprised
that you had the patience to find 1024 of them.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
Nov 14 '05 #6
On Mon, 2 Feb 2004, Kishor wrote:
Hi Friends

Click here : [URL snipped] to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...
Did anyone read the guestbook? He has hundreds of people who think his
site is great. Be afraid, be very afraid.
Thank You

Regards
Kishor


--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #7
Kishor wrote:
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...

Thank You

Regards
Kishor


Please get rid of those damn pop-up windows.
You state that the programs will compiler under Turbo C/C++ compiler.
Guess what! A lot has changed since then. Borland is now on
revision 6 or their compiler and version 5 can be downloaded for
free.

I gave up after the 4th invocation of undefined behavior.
I believe you need to get a copy of the ANSI specification
for the language.

On your "scanf" section. All the FAQs and advice in this newsgroup
specifically state to avoid the function. So, why do you put
it into your test?

Your web page is nuking my browser. Bad page, bad page.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #8
Darrell Grainger <da*****@nomorespamcs.utoronto.ca.com> spoke thus:
Did anyone read the guestbook? He has hundreds of people who think his
site is great. Be afraid, be very afraid.


Two words: sock puppets.

--
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.
Nov 14 '05 #9

On Mon, 2 Feb 2004, Thomas Matthews wrote:

Kishor wrote:

<snipped URL of that god-awful web page>
On your "scanf" section. All the FAQs and advice in this newsgroup
specifically state to avoid the function. So, why do you put
it into your test?


If "Kishor" actually knew C, 'scanf' would be a great thing to put
on a "test" or "FAQ" page. 'scanf' *can* be used safely, believe it
or not; sometimes it's even the most effective way to get things done.
Why else would it still be around? ;) But it takes a bit of skill
to write 'scanf' code that always works properly.
That skill would be a great thing to test! You know, with questions
like

Write a program that parses a text file in format X and outputs
the values it finds in fields Y and Z.

for some values of X,Y,Z. Unfortunately, "Kishor" has filled his/her
page with garbage like

What does this program do?
scanf("Hello\'u my friends,%d%g%h%i%j@87kdf", &p);

that doesn't show any understanding of the language, the concepts,
or the proper discipline required to write really good code. And
that's just bad.
[I wouldn't be too "afraid, very afraid," about the guestbook
entries. Looks like personal friends of "Kishor," presumably also
in whatever beginning C course he/she is.]

-Arthur
Nov 14 '05 #10
na***********@rediffmail.com (Kishor) wrote in message news:<84*************************@posting.google.c om>...
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...

Thank You

Regards
Kishor


--------------------------------------------------

Doesnt' that site needs to be updated. They seem to still be using void main().
Nov 14 '05 #11
caroundw5h wrote:
Doesnt' that site needs to be updated. They seem to still be using void
main().


No, not updated; just corrected. The "void main" construct has never been
correct C.

--
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
Nov 14 '05 #12
On 2 Feb 2004 08:24:06 -0800, na***********@rediffmail.com (Kishor)
wrote in comp.lang.c:
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...

Thank You

Regards
Kishor


I disagree with what my esteemed colleague Richard Heathfield said, as
I am wont to do from time to time.

Please DON'T learn C and then try to teach it.

Please, PLEASE, learn C# instead and try to teach it in Microsoft
groups for that language, not here.

--
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
Nov 14 '05 #13
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
na***********@rediffmail.com (Kishor) wrote in message news:<84*************************@posting.google.c om>...
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...

Thank You

Regards
Kishor


--------------------------------------------------

Doesnt' that site needs to be updated. They seem to still be using void main().


Ah, yes, "void main()" which was part of standard C way back NEVER.

--
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
Nov 14 '05 #14
Christopher Benson-Manica wrote:
Darrell Grainger <da*****@nomorespamcs.utoronto.ca.com> spoke thus:
Did anyone read the guestbook? He has hundreds of people who
think his site is great. Be afraid, be very afraid.


Two words: sock puppets.


One word: myrmidons.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 14 '05 #15
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().
Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"We're women. We've got double standards to live up to."
- Ally McBeal
Nov 14 '05 #16
Keith Thompson <ks***@mib.org> wrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
na***********@rediffmail.com (Kishor) wrote:
Click here : www.<censored>.com to Test Your C Programming
Strengths.


What is this, a test on how many errors you can find on the site? Sorry,
I gave up after I ran out of fingers.


I'm not surprised that there were that many errors; I'm just surprised
that you had the patience to find 1024 of them.


I wasn't counting; I was gnawing one off out of frustration with every
blunder I found.

Then, before posting, I grew them back on again. Sometimes I think I
must have lizard genes, or something.

Richard
Nov 14 '05 #17
On 3 Feb 2004 06:48:55 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().

Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?


Oh, c'mon...it doesn't take a great deal of imagination to see how
void main()
would have made a lot of sense at the time:

1. Using just
main()
defaults to returning int (of course, nowadays it should be made
explicit). What if you wanted to make sure everyone knew you were
_not_ returning an int, or anything else? There was no way to do it
before the void keyword was borrowed from C++, so it seemed like a
relief to finally have a way to express that when void was added to
the language.

2. While

Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #18
Leor Zolman <le**@bdsoft.com> scribbled the following:
On 3 Feb 2004 06:48:55 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().
Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?

Oh, c'mon...it doesn't take a great deal of imagination to see how
void main()
would have made a lot of sense at the time: 1. Using just
main()
defaults to returning int (of course, nowadays it should be made
explicit). What if you wanted to make sure everyone knew you were
_not_ returning an int, or anything else? There was no way to do it
before the void keyword was borrowed from C++, so it seemed like a
relief to finally have a way to express that when void was added to
the language.
This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?
2. While


While what?

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The large yellow ships hung in the sky in exactly the same way that bricks
don't."
- Douglas Adams
Nov 14 '05 #19
On 3 Feb 2004 06:48:55 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().

Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?


Having been around C for a while, it doesn't seem like much of a
mystery to me how "void main" would have come into common use
(although I'd agree there's no excuse for thinking it was
"standard")... When void was introduced into the language, it finally
provided a way to define main() in a way that means "I'm not returning
anything". This could reasonably be labeled a questionable practice on
Unix (K&R's platform, where it is always trivial to test a process's
exit status one way or another from shell script or system calls).
However, just look at the hoops DOS batch files have always made
folks jump through in order to deal with an exit status. How many
people really understand how ERRORLEVEL works, or bother with it once
they learn? It makes sense in that context to "formally" inform people
reading the source code that they are off the hook WRT the exit status
of that program...and defining main to return void seems like a pretty
straightforward way to say that.

Another point in "void main"'s favor is simple consistency; if every
other function not returning anything can be declared with void, why
single out main to the contrary? Sure, we're talking about a
"different kind of return", but can you _imagine_ how that might not
sit well with folks learning C?

Time marches on, now in strict mode it's an error. That's fine with
me. As for anyone playing "C teacher" who uses it ... I really liked
the "Be afraid" comment ... ;-)
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #20
On Tue, 3 Feb 2004, Joona I Palaste wrote:
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().
Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?


Having taught fist year programming I can tell you were a number of my
students got the idea that "void main()" was acceptable...

If you see "main()" without a return type specified then there is NOTHING
in front of main so the return type is NOTHING, a.k.a. "void main()".

For someone who has never programmed it makes sense, i.e. it is a good
rationalization. Add to this instructors who do not correct the students
and these students grow up to become professional programmers who believe
"void main()" is equivalent to "main()".
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"We're women. We've got double standards to live up to."
- Ally McBeal


--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #21
Darrell Grainger wrote:
fist year programming


"void mani()"?
Nov 14 '05 #22
Aplogies, group. My finger slipped while composing the message above
(in Agent, I typed control-N by accident)...the result seemed to be
that my draft was instantly posted. But I didn't know it; I thought
it was just wiped out, so wrote it over and _that_ post is below.
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #23
On 3 Feb 2004 14:21:53 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:

This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?


See my apology above, and my post below for the answer to that
question (which I didn't get the chance to type in the first time ;-)
-leor

Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #24
Leor Zolman <le**@bdsoft.com> scribbled the following:
On 3 Feb 2004 14:21:53 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?
See my apology above, and my post below for the answer to that
question (which I didn't get the chance to type in the first time ;-)


So the only reason not to return an int is to make a DOS batchfile that
doesn't use ERRORLEVEL? This is still illogical. Returning an int does
not make you *use* that int, you know. It's still fully possible to
ignore the ERRORLEVEL thingies completely and *still* say within ISO
standard C code.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Immanuel Kant but Genghis Khan."
- The Official Graffitist's Handbook
Nov 14 '05 #25
On 3 Feb 2004 14:45:21 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
Leor Zolman <le**@bdsoft.com> scribbled the following:
On 3 Feb 2004 14:21:53 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote:
This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?

See my apology above, and my post below for the answer to that
question (which I didn't get the chance to type in the first time ;-)


So the only reason not to return an int is to make a DOS batchfile that
doesn't use ERRORLEVEL? This is still illogical. Returning an int does
not make you *use* that int, you know. It's still fully possible to
ignore the ERRORLEVEL thingies completely and *still* say within ISO
standard C code.


My comments were in response to an open-ended question about how "void
main" might have come into "popular" use, and I'm describing the
situation in a time frame circa 1982-1988 (pre ANSI/ISO C). I agree
with you 100% about the situation _today_.
-leor
Leor Zolman
BD Software
le**@bdsoft.com
www.bdsoft.com -- On-Site Training in C/C++, Java, Perl & Unix
C++ users: Download BD Software's free STL Error Message
Decryptor at www.bdsoft.com/tools/stlfilt.html
Nov 14 '05 #26
Thomas Matthews wrote:
Please get rid of those damn pop-up windows.


<OT>
That's why I embraced Mozilla as my browser (although not my newsreader,
I didn't like the way it looked). The tabbed browsing didn't hurt at
all.
</OT>


Brian Rodenborn
Nov 14 '05 #27
On 3 Feb 2004 06:48:55 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote in comp.lang.c:
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
in comp.lang.c:
Doesnt' that site needs to be updated. They seem to still be using void main().

Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?


Perhaps because as compilers got smarter they began to issue warnings
for functions defined "main()" that ended without a return statement,
knowing that the definition implicitly promised to return an int and
then broke the promise.

Or maybe it's just the Microsoft help files.

The latest version of Visual C++ I have used as a C compiler (6.0 bug
fix^w^w service pack ULONG_MAX) tries to amuse you when you test for
C99 conformance.

If you define:

int main()
{
/* anything except a return statement */
}

....it will tell you that you didn't return anything, and it is going
to assume that your "int" was a typo for "void".

--
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
Nov 14 '05 #28
Jack Klein <ja*******@spamcop.net> scribbled the following:
On 3 Feb 2004 06:48:55 GMT, Joona I Palaste <pa*****@cc.helsinki.fi>
wrote in comp.lang.c:
Jack Klein <ja*******@spamcop.net> scribbled the following:
> On 2 Feb 2004 18:26:58 -0800, ca********@yahoo.com (caroundw5h) wrote
> in comp.lang.c:
>> Doesnt' that site needs to be updated. They seem to still be using void main().
> Ah, yes, "void main()" which was part of standard C way back NEVER.


I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all. As you and Richard
correctly say, void main() was never used in any form of standard C,
and it wasn't used in K&R C either. (They simply used main().) Have
those people invented it out of thin air and then started convincing
themselves it was standard C?

Perhaps because as compilers got smarter they began to issue warnings
for functions defined "main()" that ended without a return statement,
knowing that the definition implicitly promised to return an int and
then broke the promise.
Doesn't the C standard say that main() is a special case where failing
to return anything from an int function is defined behaviour?
Or maybe it's just the Microsoft help files.
Where did Microsoft get it from?
The latest version of Visual C++ I have used as a C compiler (6.0 bug
fix^w^w service pack ULONG_MAX) tries to amuse you when you test for
C99 conformance. If you define: int main()
{
/* anything except a return statement */
} ...it will tell you that you didn't return anything, and it is going
to assume that your "int" was a typo for "void".


Bleargh. Well, that's Microsoft for you. Give them a standard and the
first thing they do is try to break it.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"He said: 'I'm not Elvis'. Who else but Elvis could have said that?"
- ALF
Nov 14 '05 #29
> > Click here : (url removed) to Test Your C Programming

Hm, let me try a few of those printf questions:

[Q001] - Undefined behavior, since main() must return an int.
[Q002] - Undefined behavior, since main() must return an int.
[Q003] - Undefined behavior, since main() must return an int.
[Q004] - Undefined behavior, since main() must return an int.
[Q005] - Undefined behavior, since main() must return an int.
[Q006] - Undefined behavior, since main() must return an int.

Oh well, this is getting boring. Back to work.


I've heard that the program behaviour is still defined in this case,
but its exit status is undefined (ie. the program will still do
what it is meant to do (barring any other errors!) , at least up until
after its point of termination.
Nov 14 '05 #30
> >>>> Doesnt' that site needs to be updated. They seem to still be using void main().
Ah, yes, "void main()" which was part of standard C way back NEVER.
I have often wondered where not only newbies, but book authors, got the
idea that void main() was any form of C at all.

Oh, c'mon...it doesn't take a great deal of imagination to see how
void main()
would have made a lot of sense at the time:

1. Using just
main()
defaults to returning int (of course, nowadays it should be made
explicit). What if you wanted to make sure everyone knew you were
_not_ returning an int, or anything else? There was no way to do it
before the void keyword was borrowed from C++, so it seemed like a
relief to finally have a way to express that when void was added to
the language.


This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?


It's common practice (and recommended style by many) to make
functions not return a value, if the purpose of the function
does not include returning an informative value.

If one fails to understand C program startup, it's natural
to extend this practice to main().

Compounding the problem was the facts:
- most noobs use dos/windows
- the most common dos/windows noob compiler was Borland
- Borland allowed "void main()" and even included examples of it (IIRC)
Nov 14 '05 #31
Old Wolf <ol*****@inspire.net.nz> scribbled the following:
> Click here : (url removed) to Test Your C Programming Hm, let me try a few of those printf questions:

[Q001] - Undefined behavior, since main() must return an int.
[Q002] - Undefined behavior, since main() must return an int.
[Q003] - Undefined behavior, since main() must return an int.
[Q004] - Undefined behavior, since main() must return an int.
[Q005] - Undefined behavior, since main() must return an int.
[Q006] - Undefined behavior, since main() must return an int.

Oh well, this is getting boring. Back to work.

I've heard that the program behaviour is still defined in this case,
but its exit status is undefined (ie. the program will still do
what it is meant to do (barring any other errors!) , at least up until
after its point of termination.


You've heard wrong. The ISO C standard allows a program which defines
main() as void to do *anything it bloody well wants to*, and still be
within the bounds of legal behaviour.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"You can pick your friends, you can pick your nose, but you can't pick your
relatives."
- MAD Magazine
Nov 14 '05 #32
Old Wolf <ol*****@inspire.net.nz> scribbled the following:
>>>> Doesnt' that site needs to be updated. They seem to still be using void main().
>>> Ah, yes, "void main()" which was part of standard C way back NEVER.
>>I have often wondered where not only newbies, but book authors, got the
>>idea that void main() was any form of C at all.
> Oh, c'mon...it doesn't take a great deal of imagination to see how
> void main()
> would have made a lot of sense at the time:
> 1. Using just
> main()
> defaults to returning int (of course, nowadays it should be made
> explicit). What if you wanted to make sure everyone knew you were
> _not_ returning an int, or anything else? There was no way to do it
> before the void keyword was borrowed from C++, so it seemed like a
> relief to finally have a way to express that when void was added to
> the language.


This does not answer the question. *WHY* would you want to make sure
everyone knew you were not returning an int? *WHY* would you not want
to return an int in the first place?

It's common practice (and recommended style by many) to make
functions not return a value, if the purpose of the function
does not include returning an informative value. If one fails to understand C program startup, it's natural
to extend this practice to main(). Compounding the problem was the facts:
- most noobs use dos/windows
- the most common dos/windows noob compiler was Borland
- Borland allowed "void main()" and even included examples of it (IIRC)


So... where did Borland get it from? Someone must have originally
invented it.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
Nov 14 '05 #33
Keith Thompson wrote:
Richard Bos wrote:
What is this, a test on how many errors you can find on the site?
Sorry, I gave up after I ran out of fingers.


I'm not surprised that there were that many errors; I'm just
surprised that you had the patience to find 1024 of them.


Obviously he used base 1, not base 2.

Nov 14 '05 #34
na***********@rediffmail.com (Kishor) wrote in message news:<84*************************@posting.google.c om>...
Hi Friends

Click here : www.c4swimmers.esmartguy.com to Test Your C Programming
Strengths.
You can find Tricky Questions on C, Interview type queries on C,
Infrequently Answered Questions in C and many more...


Great effort. I really appreciate your hard work; you might have
sacrificed a lot to produce such a great site. I wish your site should
evolve more with lot of free and good stuffs.

By the way, you must understand the fact that C is about 30 years
old and most of the people present in this group are well experienced
C programmers/experts; few of them are even well renowned book
authors. You might have read the FAQ of this group
<http://groups.google.com/groups?selm=2004Feb01.0600.scs.0001%40eskimo.com>
So, you may consider using "humble" tone in old newsgroups like this.
(Don't mistaken me. Just my thoughts...)

All the best! Keep up your good work!

--
"Success = 10% sweat + 90% tears"
http://guideme.itgo.com/atozofc/ - "A to Z of C" Project
Email: rrjanbiah-at-Y!com
Nov 14 '05 #35

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

Similar topics

34
by: Pmb | last post by:
Hi. I'm new to this group. I'm refreshing/learning C++ and am starting to learn Object Oriented Programming (OOP). In discussing this with people I came up short as to what the benefits of OOP are....
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
3
by: Siddharth Jain | last post by:
Hello, Could someone please tell me the history of GUI programming for windows. In the early days, we had to write 100s of lines of code to make a simple dialog box. Then along came MFC to...
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
7
by: David Levine | last post by:
Hello, I want to get information on unit test and related (e.g. mock object) products available for managed code. What products are available and what do you think about them? Which are the...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
3
by: Paul | last post by:
Looking for recommendations on a programming language for a web application. I am soliciting recommendations on a programming language for a web application described below. Actually, it is not...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
0
by: Reedick, Andrew | last post by:
<snip> I have a Perl background and have found the O'Reilly books to be useful. The Learning Python book (or whatever it's called) is good because it covers the paradigm shifts and potential...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.