A
Antoninus Twink
I assume you are you referring to Jack who started this?
I'm afraid not.
You've expressed disagreement with the CLC mafia, ergo you are a troll.
I assume you are you referring to Jack who started this?
At the time C++ was a superset of C.
Chris said:But starting with
void main ()
which is not strictly conforming for a hosted environment is probably
going to be accepted by most compilers.
I would expect an adult to read it as a main with no parameters or
return. Not produce the sort of childish reaction it got.
Hans said:1. in the prg bellow what vars are stored on stack, heap, data segment?
int i;
void main() {
int j;
int *k = (void *)malloc(1);
}
(I think j and k are on stack, but where is i?)
2. how to find sizeof variable w/o using sizeof command?
(no clue)
3. what is the o/p of this prg?
void main() {
int x = 5;
x = x++;
printf("x=%i", x);
}
(I think it shoulld be printing 5 but it prints 6!)
ps: I am using QuickC 2.0
pps: Is very urgent!
Chris said:.... snip ...
Possibly but I think it is far more likely they were not there to
save typing. In most programming books for example K&R 2nd ed
main is
main ()
Chris said:The post from Jack is a classic example of
why c.l.c is getting such a bad name for itself.
However that said,
this is nto a place to get last minute homework done.
Why?
Chris said:...
It is valid C... for reasons of brevity the headers were not included.
Heap: malloc()ed memory1. in the prg bellow what vars are stored on stack, heap, data segment?
A return type of void works for main(); however, a non-int return typeint i; On the outermost stack frame.
void main()
k is stored in main()'s stack frame. It contains an address to heap{
int j; main()'s stack frame.
int *k = (void *)malloc(1);
sizeof is a compiler (not preprocessor) macro. During compilation, the2. how to find sizeof variable w/o using sizeof command?
x = x++ is undefined, but judging on how ++ works, I think the program3. what is the o/p of this prg?
void main()
{
int x = 5;
x = x++;
printf("x=%i", x);
}
You're using DOS. That's a bit of a help - it lets me type out valid,ps: I am using QuickC 2.0
Sounds like a homework question. I explained it to the best (read mostpps: Is very urgent!
Jack said:On Tue, 15 Jan 2008 03:41:56 +0100 (CET), Hans Schneider
For it to be a C question, urgent or not, it would have to be about
valid C code.
The line above generates undefined behavior, not valid C code.
The line above generates undefined behavior, not valid C code.
The line above generates undefined behavior, not valid C code.
Since there is no prototype for printf() in scope, this causes
undefined behavior, not valid C code.
I think it should print, "This code was written by an idiot!".
Sorry, non of these is a question about the C language. If you are in
an actual C programming course, and your instructor asked these
questions for a homework assignment, do the following:
1. Immediately drop the class.
2. Complain to the school administration about the unqualified
instructor and erroneous material.
Only when x++ is defined, such asJack Klein schrieb:
I didn't write this code, but what is wrong about it?
In 'C: the complete reference' all prgs start like that.
Is x++ not the same as x=x+1?
Mental note: QuickC is a retarded compiler.QuickC didn't complain.
*GOOD*lcc-win32 prints lots of warnings.
Methinks ambiguous prototype: main(void) or main(int, char **)?Warning test.c: 3 old-style function definition for 'main'
Warning test.c: 3 missing prototype for 'main'
Warning test.c: 3 'void main()' is a non-ANSI definition Non-int return type.
Warning test.c: 6 missing prototype for printf
Warning test.c: 6 Missing prototype for 'printf'
Read the links on the C FAQ that I posted earlier.Missing said:0 errors, 5 warnings
What do they mean?
Why are there 2 warnings on line 6?
I think it should print, "This code was written by an idiot!".
With MS QuickC and GCC it prints 6.
With lcc-win32 it prints 5. Which one prints 42?[1]
But gcc says 'operation on x may be undefined'.
I'll have to investigate why.
Advanced? WTF!?!I can't!
It is required for an advanced class.
You're screwed thenI don't think that's gonna work.
He is a cousin of the principal.
The post from Jack is a classic example of why c.l.c is getting such a
bad name for itself.
However that said, this is nto a place to get last minute homework done.
It is valid C... just not strictly conforming .
How does it's undefined behaviour impinge on the question asked?
It is valid C... for reasons of brevity the headers were not included.
However your pedantry is irrelevant to answering the question at hand.
Yes it is. Unless you are an internationally obtuse pedant. Try
communicating with humans once in a while
It is valid C... just not strictly conforming .
How does it's undefined behaviour impinge on the question asked?
Why?
The headers were omitted in this code fragment for brevity.
Assuming the headers were there what is the problem?
No the OP is ignorant. You are just insulting and not much of a person.
Try communicating with people occasionally.
They are but you don't have the breath of intelligence or common sense
to understand. You must be a liability if you have to work with humans,
Ignore Jack.
Keep going but do your own homework and don't do it at the last
minute.
But do remember as he can actually communicate with his human class he
is probably going to be better than Jack.
Is x++ not the same as x=x+1?
QuickC didn't complain.
lcc-win32 prints lots of warnings.
Warning test.c: 3 old-style function definition for 'main'
Warning test.c: 3 missing prototype for 'main'
Warning test.c: 3 'void main()' is a non-ANSI definition
Warning test.c: 6 missing prototype for printf
Warning test.c: 6 Missing prototype for 'printf'
0 errors, 5 warnings
the answers are specific to your environment. i take this risk ofHans Schneider said:1. in the prg bellow what vars are stored on stack, heap, data segment?
int i;
void main()
{
int j;
int *k = (void *)malloc(1);
}
(I think j and k are on stack, but where is i?)
2. how to find sizeof variable w/o using sizeof command?
(no clue)
3. what is the o/p of this prg?
void main()
{
int x = 5;
x = x++;
printf("x=%i", x);
}
(I think it shoulld be printing 5 but it prints 6!)
ps: I am using QuickC 2.0
pps: Is very urgent!
So that the programmer can *QUickl*ly*C* that Microsoft products areFinal Note: Why is the compiler called QuickC ?
Hans said:I didn't write this code, but what is wrong about it?
In 'C: the complete reference' all prgs start like that.
I had seen a post which used pointer arithmetic. Its subject to correction
by the experts:
sizeof(i) == ((&i) + 1) - (&i))
Perhaps useful for your assignment
Walter Roberson said:The result of that would always be 1, for any variable of any type.
You missed a couple of casts.
So that the programmer can *QUickl*ly*C* that Microsoft products are
standards-incompliant in the worst case.![]()
One billions flies can't be wrong: dung tasts greatHans said:I didn't write this code, but what is wrong about it?
In 'C: the complete reference' all prgs start like that.
Richard Heathfield said:Chris Hills said:
C++ has never been a superset of C.
If it were, all C programs would be C++
programs, which is clearly not the case.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.