Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Example Needed

3 views
Skip to first unread message

Thompson Reed

unread,
Jun 4, 2008, 1:45:36 AM6/4/08
to
Can someone give me an example C program with at least 20 lines of
source code. That is the requirement and a line of code is a semicolon
according to the rules. I have a job interview on Friday and they want
this the day before the interview. I am not a C expert like many of you
but I am a hard worker and I need this job. Please help a brother and
American patriot in need.

Thanks in advance -- Thompson R.

vipp...@gmail.com

unread,
Jun 4, 2008, 1:51:01 AM6/4/08
to

int main(void) { return 0;;;;;;;;;;;;;;;;;;;; }

Keith Thompson

unread,
Jun 4, 2008, 1:52:46 AM6/4/08
to

I'd be happier if the job went to someone who's actually able to write
a program himself, or at least who didn't try to cheat on a job
interview.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

rahul

unread,
Jun 4, 2008, 4:53:39 AM6/4/08
to
Even if you are trying to cheat, I didn't quite get the situation.
Won't it be easier for you to google an algorithm and study the
implementation. And what kind of job you are vying for which requires
you to bring 20 lines of C code doing anything with you?

Ian Collins

unread,
Jun 4, 2008, 4:55:22 AM6/4/08
to
rahul wrote:

What are you replying to?

Please retain context.


--
Ian Collins.

Fred Yu

unread,
Jun 4, 2008, 5:16:14 AM6/4/08
to
Very interesting.

"Keith Thompson" <ks...@mib.org> ??????:ln1w3d7...@nuthaus.mib.org...

Bartc

unread,
Jun 4, 2008, 5:32:06 AM6/4/08
to

"Thompson Reed" <tree...@botsview.com> wrote in message
news:kZp1k.136$6%5....@newsfe07.lga...

Plenty of such examples here, and on the rest of the internet, and in
books...

But what will you do on your first day at work if you get the job?

Out of interest what was your last job?

-- bartc

Ron Ford

unread,
Jun 4, 2008, 5:42:09 AM6/4/08
to
On Tue, 03 Jun 2008 22:52:46 -0700, Keith Thompson wrote:

> Thompson Reed <tree...@botsview.com> writes:
>> Can someone give me an example C program with at least 20 lines of
>> source code. That is the requirement and a line of code is a semicolon
>> according to the rules. I have a job interview on Friday and they want
>> this the day before the interview. I am not a C expert like many of
>> you but I am a hard worker and I need this job. Please help a brother
>> and American patriot in need.
>>
>> Thanks in advance -- Thompson R.
>
> I'd be happier if the job went to someone who's actually able to write
> a program himself, or at least who didn't try to cheat on a job
> interview.

Start with int main.

Ask whether processing command line args is relevant. If not, then let
main expect nothing: make its argument void.

Beyond that, try to spell correctly, which is how I usually commend federal
officers. Be more portable than Jabba the Hut. Good luck,
--
Ron Ford

Richard Heathfield

unread,
Jun 4, 2008, 7:01:10 AM6/4/08
to
Ron Ford said:

<snip>


>
> Beyond that, try to spell correctly, which is how I usually commend
> federal officers. Be more portable than Jabba the Hut.

That's "Hutt". Congratulations on retaining a cents of tradition where
spelling flames are concerned.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999

Charlton Wilbur

unread,
Jun 4, 2008, 9:56:43 AM6/4/08
to
>>>>> "TR" == Thompson Reed <tree...@botsview.com> writes:

TR> Can someone give me an example C program with at least 20 lines
TR> of source code. That is the requirement and a line of code is a
TR> semicolon according to the rules. I have a job interview on
TR> Friday and they want this the day before the interview. I am not
TR> a C expert like many of you but I am a hard worker and I need
TR> this job.

You realize that, if the interviewer is at all good, he or she will ask
you what the program does, and probably ask you to answer some technical
C questions and write another 20 or so lines of code in the actual
interview?

And you realize that HR people talk to other HR people from other
companies - a lot?

So the likely outcome of someone sending you code -- assuming they send
you correct code, in an effort to help -- is that you get into the
interview, the interviewer realizes you have no C skills at all, the
interview ends, and word gets out that you're a fraud.

*Not* the outcome I'd hope for.

TR> Please help a brother and American patriot in need.

If you were my brother, you'd have enough self-respect to not do such an
asinine thing. And calling yourself an "American patriot" while
attempting to perpetrate a fraud is disgraceful.

Charlton

--
Charlton Wilbur
cwi...@chromatico.net

Lew Pitcher

unread,
Jun 4, 2008, 10:19:20 AM6/4/08
to
In comp.lang.c, Thompson Reed wrote:

> Can someone give me an example C program with at least 20 lines of

> source code.That is the requirement and a line of code is a semicolon

> according to the rules. I have a job interview on Friday and they want
> this the day before the interview.

May I suggest the code at http://www0.us.ioccc.org/2000/dhyang.c ?

> I am not a C expert like many of you but I am a hard worker and I need
> this job.

[snip]


--
Lew Pitcher

Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------


user923005

unread,
Jun 4, 2008, 2:46:08 PM6/4/08
to
On Jun 3, 10:45 pm, Thompson Reed <treed1...@botsview.com> wrote:
> Can someone give me an example C program with at least 20 lines of
> source code. That is the requirement and a line of code is a semicolon
> according to the rules.

That simplifies things:
void i void(){;;;;;;;;;;;;;;;;;;;;}

>I have a job interview on Friday and they want
> this the day before the interview. I am not a C expert like many of you
> but I am a hard worker and I need this job.

I won't apply for a brain surgeon's position. Do you know why?
Because I don't know how to operate on brains.

> Please help a brother and
> American patriot in need.

One of the better trolls I have seen lately. Pretty funny, actually.

user923005

unread,
Jun 4, 2008, 2:52:20 PM6/4/08
to
On Jun 4, 11:46 am, user923005 <dcor...@connx.com> wrote:
> On Jun 3, 10:45 pm, Thompson Reed <treed1...@botsview.com> wrote:
>
> > Can someone give me an example C program with at least 20 lines of
> > source code. That is the requirement and a line of code is a semicolon
> > according to the rules.
>
> That simplifies things:
> void i void(){;;;;;;;;;;;;;;;;;;;;}

Hey, one defect in 20 lines isn't that bad.
void i (void){;;;;;;;;;;;;;;;;;;;;}

Ron Ford

unread,
Jun 5, 2008, 12:32:09 AM6/5/08
to
On Wed, 04 Jun 2008 11:01:10 +0000, Richard Heathfield wrote:

> Ron Ford said:
>
> <snip>
>>
>> Beyond that, try to spell correctly, which is how I usually commend
>> federal officers. Be more portable than Jabba the Hut.
>
> That's "Hutt". Congratulations on retaining a cents of tradition where
> spelling flames are concerned.

I wrote a perl program that read the subject of a usenet message, and if it
contained the word "jabba," then the output was to be the words of the
subject with the ultimate word reversed. I thought I succeeded when the
output was "jabba the tuh." Apparently not.
--
Ron Ford

John J. Smith

unread,
Jun 5, 2008, 10:45:05 PM6/5/08
to
Thompson Reed wrote:

> Can someone give me an example C program with at least 20 lines of
> source code.

Sure.

> That is the requirement and a line of code is a semicolon
> according to the rules.

$ grep ';' sample.c | wc -l
101

> I have a job interview on Friday and they want
> this the day before the interview. I am not a C expert like many of you
> but I am a hard worker and I need this job. Please help a brother and
> American patriot in need.
>
> Thanks in advance -- Thompson R.


(As an exercise, write a C program that can generate the
program below... many interviewers are very impressed by that)


/* begin sample.c */
#include <stdio.h>

#define PRINTSIZE(t) \
do { \
fprintf(stdout, "%-32s: %lu\n", \
"sizeof(" #t ")", \
(unsigned long)sizeof(t)); \
} while(0)

int main(void)
{
PRINTSIZE(char);
PRINTSIZE(signed char);
PRINTSIZE(char signed);
PRINTSIZE(unsigned char);
PRINTSIZE(char unsigned);
PRINTSIZE(short);
PRINTSIZE(signed short);
PRINTSIZE(short signed);
PRINTSIZE(short int);
PRINTSIZE(int short);
PRINTSIZE(signed short int);
PRINTSIZE(signed int short);
PRINTSIZE(short signed int);
PRINTSIZE(short int signed);
PRINTSIZE(int signed short);
PRINTSIZE(int short signed);
PRINTSIZE(unsigned short);
PRINTSIZE(short unsigned);
PRINTSIZE(unsigned short int);
PRINTSIZE(unsigned int short);
PRINTSIZE(short unsigned int);
PRINTSIZE(short int unsigned);
PRINTSIZE(int unsigned short);
PRINTSIZE(int short unsigned);
PRINTSIZE(int);
PRINTSIZE(signed);
PRINTSIZE(signed int);
PRINTSIZE(int signed);
PRINTSIZE(unsigned);
PRINTSIZE(unsigned int);
PRINTSIZE(int unsigned);
PRINTSIZE(long);
PRINTSIZE(signed long);
PRINTSIZE(long signed);
PRINTSIZE(long int);
PRINTSIZE(int long);
PRINTSIZE(signed long int);
PRINTSIZE(signed int long);
PRINTSIZE(long signed int);
PRINTSIZE(long int signed);
PRINTSIZE(int signed long);
PRINTSIZE(int long signed);
PRINTSIZE(unsigned long);
PRINTSIZE(long unsigned);
PRINTSIZE(unsigned long int);
PRINTSIZE(unsigned int long);
PRINTSIZE(long unsigned int);
PRINTSIZE(long int unsigned);
PRINTSIZE(int unsigned long);
PRINTSIZE(int long unsigned);

#if __STDC_VERSION__ >= 199901L
PRINTSIZE(long long);
PRINTSIZE(signed long long);
PRINTSIZE(long signed long);
PRINTSIZE(long long signed);
PRINTSIZE(long long int);
PRINTSIZE(long int long);
PRINTSIZE(int long long);
PRINTSIZE(signed long long int);
PRINTSIZE(signed long int long);
PRINTSIZE(signed int long long);
PRINTSIZE(long signed long int);
PRINTSIZE(long signed int long);
PRINTSIZE(long long signed int);
PRINTSIZE(long long int signed);
PRINTSIZE(long int signed long);
PRINTSIZE(long int long signed);
PRINTSIZE(int signed long long);
PRINTSIZE(int long signed long);
PRINTSIZE(int long long signed);
PRINTSIZE(unsigned long long);
PRINTSIZE(long unsigned long);
PRINTSIZE(long long unsigned);
PRINTSIZE(unsigned long long int);
PRINTSIZE(unsigned long int long);
PRINTSIZE(unsigned int long long);
PRINTSIZE(long unsigned long int);
PRINTSIZE(long unsigned int long);
PRINTSIZE(long long unsigned int);
PRINTSIZE(long long int unsigned);
PRINTSIZE(long int unsigned long);
PRINTSIZE(long int long unsigned);
PRINTSIZE(int unsigned long long);
PRINTSIZE(int long unsigned long);
PRINTSIZE(int long long unsigned);
#endif

PRINTSIZE(float);
PRINTSIZE(double);
PRINTSIZE(long double);
PRINTSIZE(double long);

#if __STDC_VERSION__ >= 199901L
PRINTSIZE(_Bool);
PRINTSIZE(float _Complex);
PRINTSIZE(_Complex float);
PRINTSIZE(double _Complex);
PRINTSIZE(_Complex double);
PRINTSIZE(long double _Complex);
PRINTSIZE(long _Complex double);
PRINTSIZE(double long _Complex);
PRINTSIZE(double _Complex long);
PRINTSIZE(_Complex long double);
PRINTSIZE(_Complex double long);
#endif

return 0;
}
/* end sample.c */

--
John J. Smith

jaysome

unread,
Jun 6, 2008, 2:23:48 AM6/6/08
to
On Fri, 6 Jun 2008 04:45:05 +0200 (CEST), John J. Smith
<j...@localhost.invalid> wrote:

>Thompson Reed wrote:
>
>> Can someone give me an example C program with at least 20 lines of
>> source code.
>
>Sure.
>
>> That is the requirement and a line of code is a semicolon
>> according to the rules.
>
>$ grep ';' sample.c | wc -l

C:\clc> grep ';' sample.c | wc -l

'grep' is not recognized as an internal or external command,
operable program or batch file.

[snip OP's drivel]

>(As an exercise, write a C program that can generate the
>program below... many interviewers are very impressed by that)

Count me out as an interviewer who is not impressed by the generated
program.

[snip program]

Compiling...
sample.c
sample.c(13) : warning C4127: conditional expression is constant
sample.c(14) : warning C4127: conditional expression is constant
sample.c(15) : warning C4127: conditional expression is constant
sample.c(16) : warning C4127: conditional expression is constant
sample.c(17) : warning C4127: conditional expression is constant
sample.c(18) : warning C4127: conditional expression is constant
sample.c(19) : warning C4127: conditional expression is constant
sample.c(20) : warning C4127: conditional expression is constant
sample.c(21) : warning C4127: conditional expression is constant
sample.c(22) : warning C4127: conditional expression is constant
sample.c(23) : warning C4127: conditional expression is constant
sample.c(24) : warning C4127: conditional expression is constant
sample.c(25) : warning C4127: conditional expression is constant
sample.c(26) : warning C4127: conditional expression is constant
sample.c(27) : warning C4127: conditional expression is constant
sample.c(28) : warning C4127: conditional expression is constant
sample.c(29) : warning C4127: conditional expression is constant
sample.c(30) : warning C4127: conditional expression is constant
sample.c(31) : warning C4127: conditional expression is constant
sample.c(32) : warning C4127: conditional expression is constant
sample.c(33) : warning C4127: conditional expression is constant
sample.c(34) : warning C4127: conditional expression is constant
sample.c(35) : warning C4127: conditional expression is constant
sample.c(36) : warning C4127: conditional expression is constant
sample.c(37) : warning C4127: conditional expression is constant
sample.c(38) : warning C4127: conditional expression is constant
sample.c(39) : warning C4127: conditional expression is constant
sample.c(40) : warning C4127: conditional expression is constant
sample.c(41) : warning C4127: conditional expression is constant
sample.c(42) : warning C4127: conditional expression is constant
sample.c(43) : warning C4127: conditional expression is constant
sample.c(44) : warning C4127: conditional expression is constant
sample.c(45) : warning C4127: conditional expression is constant
sample.c(46) : warning C4127: conditional expression is constant
sample.c(47) : warning C4127: conditional expression is constant
sample.c(48) : warning C4127: conditional expression is constant
sample.c(49) : warning C4127: conditional expression is constant
sample.c(50) : warning C4127: conditional expression is constant
sample.c(51) : warning C4127: conditional expression is constant
sample.c(52) : warning C4127: conditional expression is constant
sample.c(53) : warning C4127: conditional expression is constant
sample.c(54) : warning C4127: conditional expression is constant
sample.c(55) : warning C4127: conditional expression is constant
sample.c(56) : warning C4127: conditional expression is constant
sample.c(57) : warning C4127: conditional expression is constant
sample.c(58) : warning C4127: conditional expression is constant
sample.c(59) : warning C4127: conditional expression is constant
sample.c(60) : warning C4127: conditional expression is constant
sample.c(61) : warning C4127: conditional expression is constant
sample.c(62) : warning C4127: conditional expression is constant
sample.c(101) : warning C4127: conditional expression is constant
sample.c(102) : warning C4127: conditional expression is constant
sample.c(103) : warning C4127: conditional expression is constant
sample.c(104) : warning C4127: conditional expression is constant

sample.obj - 0 error(s), 54 warning(s)

PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
1985-2006

--- Module: sample.c (C)
_
PRINTSIZE(char);
sample.c(13) : Info 717: do ... while(0);
_
PRINTSIZE(signed char);
sample.c(14) : Info 717: do ... while(0);
_
PRINTSIZE(char signed);
sample.c(15) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned char);
sample.c(16) : Info 717: do ... while(0);
_
PRINTSIZE(char unsigned);
sample.c(17) : Info 717: do ... while(0);
_
PRINTSIZE(short);
sample.c(18) : Info 717: do ... while(0);
_
PRINTSIZE(signed short);
sample.c(19) : Info 717: do ... while(0);
_
PRINTSIZE(short signed);
sample.c(20) : Info 717: do ... while(0);
_
PRINTSIZE(short int);
sample.c(21) : Info 717: do ... while(0);
_
PRINTSIZE(int short);
sample.c(22) : Info 717: do ... while(0);
_
PRINTSIZE(signed short int);
sample.c(23) : Info 717: do ... while(0);
_
PRINTSIZE(signed int short);
sample.c(24) : Info 717: do ... while(0);
_
PRINTSIZE(short signed int);
sample.c(25) : Info 717: do ... while(0);
_
PRINTSIZE(short int signed);
sample.c(26) : Info 717: do ... while(0);
_
PRINTSIZE(int signed short);
sample.c(27) : Info 717: do ... while(0);
_
PRINTSIZE(int short signed);
sample.c(28) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned short);
sample.c(29) : Info 717: do ... while(0);
_
PRINTSIZE(short unsigned);
sample.c(30) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned short int);
sample.c(31) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned int short);
sample.c(32) : Info 717: do ... while(0);
_
PRINTSIZE(short unsigned int);
sample.c(33) : Info 717: do ... while(0);
_
PRINTSIZE(short int unsigned);
sample.c(34) : Info 717: do ... while(0);
_
PRINTSIZE(int unsigned short);
sample.c(35) : Info 717: do ... while(0);
_
PRINTSIZE(int short unsigned);
sample.c(36) : Info 717: do ... while(0);
_
PRINTSIZE(int);
sample.c(37) : Info 717: do ... while(0);
_
PRINTSIZE(signed);
sample.c(38) : Info 717: do ... while(0);
_
PRINTSIZE(signed int);
sample.c(39) : Info 717: do ... while(0);
_
PRINTSIZE(int signed);
sample.c(40) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned);
sample.c(41) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned int);
sample.c(42) : Info 717: do ... while(0);
_
PRINTSIZE(int unsigned);
sample.c(43) : Info 717: do ... while(0);
_
PRINTSIZE(long);
sample.c(44) : Info 717: do ... while(0);
_
PRINTSIZE(signed long);
sample.c(45) : Info 717: do ... while(0);
_
PRINTSIZE(long signed);
sample.c(46) : Info 717: do ... while(0);
_
PRINTSIZE(long int);
sample.c(47) : Info 717: do ... while(0);
_
PRINTSIZE(int long);
sample.c(48) : Info 717: do ... while(0);
_
PRINTSIZE(signed long int);
sample.c(49) : Info 717: do ... while(0);
_
PRINTSIZE(signed int long);
sample.c(50) : Info 717: do ... while(0);
_
PRINTSIZE(long signed int);
sample.c(51) : Info 717: do ... while(0);
_
PRINTSIZE(long int signed);
sample.c(52) : Info 717: do ... while(0);
_
PRINTSIZE(int signed long);
sample.c(53) : Info 717: do ... while(0);
_
PRINTSIZE(int long signed);
sample.c(54) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned long);
sample.c(55) : Info 717: do ... while(0);
_
PRINTSIZE(long unsigned);
sample.c(56) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned long int);
sample.c(57) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned int long);
sample.c(58) : Info 717: do ... while(0);
_
PRINTSIZE(long unsigned int);
sample.c(59) : Info 717: do ... while(0);
_
PRINTSIZE(long int unsigned);
sample.c(60) : Info 717: do ... while(0);
_
PRINTSIZE(int unsigned long);
sample.c(61) : Info 717: do ... while(0);
_
PRINTSIZE(int long unsigned);
sample.c(62) : Info 717: do ... while(0);
_
PRINTSIZE(long long);
sample.c(65) : Info 717: do ... while(0);
_
PRINTSIZE(signed long long);
sample.c(66) : Info 717: do ... while(0);
_
PRINTSIZE(long signed long);
sample.c(67) : Info 717: do ... while(0);
_
PRINTSIZE(long long signed);
sample.c(68) : Info 717: do ... while(0);
_
PRINTSIZE(long long int);
sample.c(69) : Info 717: do ... while(0);
_
PRINTSIZE(long int long);
sample.c(70) : Info 717: do ... while(0);
_
PRINTSIZE(int long long);
sample.c(71) : Info 717: do ... while(0);
_
PRINTSIZE(signed long long int);
sample.c(72) : Info 717: do ... while(0);
_
PRINTSIZE(signed long int long);
sample.c(73) : Info 717: do ... while(0);
_
PRINTSIZE(signed int long long);
sample.c(74) : Info 717: do ... while(0);
_
PRINTSIZE(long signed long int);
sample.c(75) : Info 717: do ... while(0);
_
PRINTSIZE(long signed int long);
sample.c(76) : Info 717: do ... while(0);
_
PRINTSIZE(long long signed int);
sample.c(77) : Info 717: do ... while(0);
_
PRINTSIZE(long long int signed);
sample.c(78) : Info 717: do ... while(0);
_
PRINTSIZE(long int signed long);
sample.c(79) : Info 717: do ... while(0);
_
PRINTSIZE(long int long signed);
sample.c(80) : Info 717: do ... while(0);
_
PRINTSIZE(int signed long long);
sample.c(81) : Info 717: do ... while(0);
_
PRINTSIZE(int long signed long);
sample.c(82) : Info 717: do ... while(0);
_
PRINTSIZE(int long long signed);
sample.c(83) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned long long);
sample.c(84) : Info 717: do ... while(0);
_
PRINTSIZE(long unsigned long);
sample.c(85) : Info 717: do ... while(0);
_
PRINTSIZE(long long unsigned);
sample.c(86) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned long long int);
sample.c(87) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned long int long);
sample.c(88) : Info 717: do ... while(0);
_
PRINTSIZE(unsigned int long long);
sample.c(89) : Info 717: do ... while(0);
_
PRINTSIZE(long unsigned long int);
sample.c(90) : Info 717: do ... while(0);
_
PRINTSIZE(long unsigned int long);
sample.c(91) : Info 717: do ... while(0);
_
PRINTSIZE(long long unsigned int);
sample.c(92) : Info 717: do ... while(0);
_
PRINTSIZE(long long int unsigned);
sample.c(93) : Info 717: do ... while(0);
_
PRINTSIZE(long int unsigned long);
sample.c(94) : Info 717: do ... while(0);
_
PRINTSIZE(long int long unsigned);
sample.c(95) : Info 717: do ... while(0);
_
PRINTSIZE(int unsigned long long);
sample.c(96) : Info 717: do ... while(0);
_
PRINTSIZE(int long unsigned long);
sample.c(97) : Info 717: do ... while(0);
_
PRINTSIZE(int long long unsigned);
sample.c(98) : Info 717: do ... while(0);
_
PRINTSIZE(float);
sample.c(101) : Info 717: do ... while(0);
_
PRINTSIZE(double);
sample.c(102) : Info 717: do ... while(0);
_
PRINTSIZE(long double);
sample.c(103) : Info 717: do ... while(0);
_
PRINTSIZE(double long);
sample.c(104) : Info 717: do ... while(0);
_
PRINTSIZE(_Bool);
sample.c(107) : Info 717: do ... while(0);

--
jaysome

Hans Schneider

unread,
Jun 6, 2008, 9:15:55 AM6/6/08
to
jaysome schrieb:

> On Fri, 6 Jun 2008 04:45:05 +0200 (CEST), John J. Smith
> <j...@localhost.invalid> wrote:
>
>>Thompson Reed wrote:
>>
>>> Can someone give me an example C program with at least 20 lines of
>>> source code.
>>
>>Sure.
>>
>>> That is the requirement and a line of code is a semicolon
>>> according to the rules.
>>
>>$ grep ';' sample.c | wc -l
>
> C:\clc> grep ';' sample.c | wc -l
>
> 'grep' is not recognized as an internal or external command,
> operable program or batch file.
>
> [snip OP's drivel]
>
>>(As an exercise, write a C program that can generate the
>>program below... many interviewers are very impressed by that)
>
> Count me out as an interviewer who is not impressed by the generated
> program.
>
> [snip program]
>
> Compiling...
> sample.c
> sample.c(13) : warning C4127: conditional expression is constant

[...]


> sample.c(104) : warning C4127: conditional expression is constant
>
> sample.obj - 0 error(s), 54 warning(s)
>
> PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
> 1985-2006
>
> --- Module: sample.c (C)
> _
> PRINTSIZE(char);
> sample.c(13) : Info 717: do ... while(0);
> _

[...]


> _
> PRINTSIZE(_Bool);
> sample.c(107) : Info 717: do ... while(0);
>

This builds not with LCC-WIN32 also:

Warning sample.c: 67 multiple use of 'long'
Warning sample.c: 70 multiple use of 'long'
Warning sample.c: 71 multiple use of 'longlong'
Warning sample.c: 73 multiple use of 'long'
Warning sample.c: 74 multiple use of 'longlong'
Warning sample.c: 75 multiple use of 'long'
Warning sample.c: 76 multiple use of 'long'
Warning sample.c: 77 multiple use of 'int'
Warning sample.c: 79 multiple use of 'long'
Warning sample.c: 80 multiple use of 'long'
Warning sample.c: 81 multiple use of 'longlong'
Warning sample.c: 82 multiple use of 'long'
Warning sample.c: 83 multiple use of 'longlong'
Warning sample.c: 85 multiple use of 'long'
Warning sample.c: 88 multiple use of 'long'
Warning sample.c: 89 multiple use of 'longlong'
Warning sample.c: 90 multiple use of 'long'
Warning sample.c: 91 multiple use of 'long'
Warning sample.c: 92 multiple use of 'int'
Warning sample.c: 94 multiple use of 'long'
Warning sample.c: 95 multiple use of 'long'
Warning sample.c: 96 multiple use of 'longlong'
Warning sample.c: 97 multiple use of 'long'
Warning sample.c: 98 multiple use of 'longlong'
Warning sample.c: 109 No type specified for _Complex. Defaulting to double
Warning sample.c: 109 no type specified. Defaulting to int
Error sample.c: 109 syntax error; found `float' expecting ')'
Error sample.c: 109 syntax error; found `float' expecting ')'
Error sample.c: 109 Syntax error; missing semicolon before `float'
Error sample.c: 109 empty declaration
Error sample.c: 109 Syntax error; missing semicolon before `)'
Error sample.c: 109 skipping `)' `)'
Warning sample.c: 111 No type specified for _Complex. Defaulting to double
Warning sample.c: 111 no type specified. Defaulting to int
Error sample.c: 111 syntax error; found `double' expecting ')'
Error sample.c: 111 syntax error; found `double' expecting ')'
Error sample.c: 111 Syntax error; missing semicolon before `double'
Error sample.c: 111 empty declaration
Error sample.c: 111 Syntax error; missing semicolon before `)'
Error sample.c: 111 skipping `)' `)'
Warning sample.c: 113 multiple use of 'double'
Warning sample.c: 114 multiple use of '_Complex'
Warning sample.c: 116 No type specified for _Complex. Defaulting to double
Warning sample.c: 116 no type specified. Defaulting to int
Error sample.c: 116 syntax error; found `long' expecting ')'
Error sample.c: 116 syntax error; found `long' expecting ')'
Error sample.c: 116 Syntax error; missing semicolon before `long'
Error sample.c: 116 empty declaration
Error sample.c: 116 Syntax error; missing semicolon before `)'
Error sample.c: 116 skipping `)' `)'
Warning sample.c: 117 No type specified for _Complex. Defaulting to double
Warning sample.c: 117 no type specified. Defaulting to int
Error sample.c: 117 syntax error; found `double' expecting ')'
Error sample.c: 117 syntax error; found `double' expecting ')'
Error sample.c: 117 too many errors
1 error

Flash Gordon

unread,
Jun 6, 2008, 3:45:51 PM6/6/08
to
Hans Schneider wrote, On 06/06/08 14:15:

> jaysome schrieb:
>
>> On Fri, 6 Jun 2008 04:45:05 +0200 (CEST), John J. Smith
>> <j...@localhost.invalid> wrote:
>>
>>> Thompson Reed wrote:
>>>
>>>> Can someone give me an example C program with at least 20 lines of
>>>> source code.
>>> Sure.
>>>
>>>> That is the requirement and a line of code is a semicolon
>>>> according to the rules.
>>> $ grep ';' sample.c | wc -l
>> C:\clc> grep ';' sample.c | wc -l
>>
>> 'grep' is not recognized as an internal or external command,
>> operable program or batch file.

So? That was just a quick way to show you how many semi-colons were in
the source.

>> [snip OP's drivel]
>>
>>> (As an exercise, write a C program that can generate the
>>> program below... many interviewers are very impressed by that)
>> Count me out as an interviewer who is not impressed by the generated
>> program.
>>
>> [snip program]
>>
>> Compiling...
>> sample.c
>> sample.c(13) : warning C4127: conditional expression is constant
> [...]
>> sample.c(104) : warning C4127: conditional expression is constant
>>
>> sample.obj - 0 error(s), 54 warning(s)

Well, that is 54 warnings for a common, useful and sensible trick to
allow you to use a macro in the way a lot of people would expect.

>> PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
>> 1985-2006
>>
>> --- Module: sample.c (C)
>> _
>> PRINTSIZE(char);
>> sample.c(13) : Info 717: do ... while(0);
>> _
> [...]
>> _
>> PRINTSIZE(_Bool);
>> sample.c(107) : Info 717: do ... while(0);

Again, that is generating warnings for a valid useful way of doing things.

> This builds not with LCC-WIN32 also:
>
> Warning sample.c: 67 multiple use of 'long'
> Warning sample.c: 70 multiple use of 'long'
> Warning sample.c: 71 multiple use of 'longlong'

<snip>

We've already got a thread discussing these problems.

> Warning sample.c: 109 No type specified for _Complex. Defaulting to double
> Warning sample.c: 109 no type specified. Defaulting to int
> Error sample.c: 109 syntax error; found `float' expecting ')'
> Error sample.c: 109 syntax error; found `float' expecting ')'
> Error sample.c: 109 Syntax error; missing semicolon before `float'
> Error sample.c: 109 empty declaration
> Error sample.c: 109 Syntax error; missing semicolon before `)'
> Error sample.c: 109 skipping `)' `)'

<snip>

That just looks like another example of the same problem with lcc-win32
to me.

I don't think there is anything wrong with the code posted by John Smith
and gcc agrees with me.
--
Flash Gordon

0 new messages