How to Call struct into main

Dear all,
Here is my code: It does not work and gives me an error

line 20: error: new types may not be defined in a return type
compilation terminated due to -Wfatal-errors.

The code is below:

#include <iostream>
#include <stdio.h>

struct s{
char ch;
int i;
}

union u{
char ch;
int i;
}

class c{
char ch;
int i;
}


main(){//<- Where the error points))
cout << sizeof(s);
cout << sizeof(u);
cout << sizeof(c);
}

I am using DEV C++ as a compiler
structs and classes need to end with a semicolon:

1
2
3
4
struct Foo
{
  // stuff here
};  // don't forget the ; 


main needs to return an int:

1
2
3
4
int main()  // don't forget the int
{
  //...
}


Dev C++ is Ancient. I strongly recomment you get a newer IDE.
Thank you very much Disch!
Which IDE do you recommend?
closed account (S6k9GNh0)
rjain02, DEV C++ isn't a compiler, its an IDE. I'd suggest anything from NetBeans to NotePad++.
Last edited on
Topic archived. No new replies allowed.