V
Vijay Kumar R Zanvar
Hi,
Have a look at the following program:
//++
/* struct.cpp */
#include <stdio.h>
struct {
int a;
int b;
struct {
int c;
};
}a = { 10, 12, 14};
int
main ()
{
printf ( "sizeof a = %d\n", sizeof a );
printf ( "a.a: %d a.b: %d a.c: %d\n", a.a, a.b. a.c );
return 0;
}
//--
I compiled the program using:
# g++ struct.cpp -ansi -Wall
# ./a.out
12
a.a: 10 a.b: 12 a.c: 14
OK. The program worked in Linux.
Turbo C++ 3.0 / WinNT gave the following errors:
* To many initializers
* Structure required on left side of . or .*
The -ansi option confirms ANSI compliance. Then why Turbo C++
flagged the errors?
By the way... what are applications of declaring structures
as above?
Thanks.
Have a look at the following program:
//++
/* struct.cpp */
#include <stdio.h>
struct {
int a;
int b;
struct {
int c;
};
}a = { 10, 12, 14};
int
main ()
{
printf ( "sizeof a = %d\n", sizeof a );
printf ( "a.a: %d a.b: %d a.c: %d\n", a.a, a.b. a.c );
return 0;
}
//--
I compiled the program using:
# g++ struct.cpp -ansi -Wall
# ./a.out
12
a.a: 10 a.b: 12 a.c: 14
OK. The program worked in Linux.
Turbo C++ 3.0 / WinNT gave the following errors:
* To many initializers
* Structure required on left side of . or .*
The -ansi option confirms ANSI compliance. Then why Turbo C++
flagged the errors?
By the way... what are applications of declaring structures
as above?
Thanks.