Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ structure

// Can be outside or inside the main function
struct {
  string name;
  int age;
} user_data;

// The part you use the struct
cout << "What is your name? ";
cin >> user_data.name;

cout << "How old are you? ";
cin >> user_data.age;;

cout << endl << "Hello " << user_data.name << ", You are " << user_data.age << " years old!";
 
PREVIOUS NEXT
Tagged: #structure
ADD COMMENT
Topic
Name
4+3 =