Archived

This topic is now archived and is closed to further replies.

Someone correct this simple program quickly please

This topic is 5892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve decided to try MVC++ compiler after DEV-C++ but this simple program won''t work: #include #include int main() { struct PERSON { int age; char name[20]; float height; }; PERSON Tevong; Tevong.age=16; strcpy(Tevong.name,"Tevong"); Tevong.height=1.74; cout<

Share this post


Link to post
Share on other sites
stdio.h and iostream.h didn''t paste for some reason.. I included those two.

I didn''t include string.h, in DEV-C++ it worked without having to include anything else.

I''ll try that thanks.

Share this post


Link to post
Share on other sites
quote:
Original post by Tevong
And also, is it possible to make constructors for structs as well as classes? If so, how?

structs in C++ are equivalent to classes with a default visibility (access specification) of public rather than private. Create constructors the same way you do for classes.

Share this post


Link to post
Share on other sites