Archived

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

Tevong

Someone correct this simple program quickly please

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
You also need string.h to use strcpy:

#include <stdio.h>
#include <string.h>


Edited by - nickm on October 30, 2001 1:22:08 PM

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