-
C Structure
over 8 years ago
-
over 8 years ago
Here is the general syntax of declaring a structure
struct structure_name
{
data_type variable_name1;
data_type variable_name2;
.
.
data_type variable_nameN;
};
You can create any custome data type using structure.For your first question, you can use following structure
struct node { char name[100]; char phoneNumber[16]; struct node *left; struct node *right; }For your second question you can use following structure
struct node { int left, middle, right; }
I will recommend you to check this C tutorial on structure and binary tree data structure.
-
-
over 8 years ago
When they are talking about structures in C, they mean struct. A struct is a lot like a class except a struct 's data members will be public by default.
include
struct Title{ string name; string phone_number;
};
//data type is another name for struct too
struct SSN{ string prefix ="999"; string center="99"; string post="9999"; };
Now, within the struct you can create methods to validate the numbers and other information.
-
2 Answer(s)