You are here:   HomeC Programming (Theory)Structure And UnionC Program to read and print info of a person
by Dinesh Thakur Category: Structure And Union

Structures and Unions, Giving values to members, Initializing structure, Functions and structures, Passing structure to elements to functions, Passing entire function to functions, Arrays of structure, Structure within a structure and Union.

 
by Dinesh Thakur Category: Structure And Union

A structure is a user-defined data type containing a collection of logically related data which may be of different types such as int, double, char, and so on. All of them are encapsulated (packed) in a single unit with a single name. The classes of C++ are in fact generalization of C-structures. A class in C++ with only public members is similar to a C-structure. All members of a structure in C are by default public. However, in a class declaration in C++, if there is no access specifier, the members are private by default. We know that arrays can be used to represent a group of data items that belong to the same type, such as int or float. This restriction is not there in structures.

 
by Dinesh Thakur Category: Structure And Union

Union is a collection of data items of different data types. It can hold data of only one member at a time though it has members of different data types. If a union has two members of different data types, they are allocated the same memory.



 
by Dinesh Thakur Category: Structure And Union

A program to determine the number of words and average word length is given in Program. It uses the strtok function to separate the words in a given string. The program given below uses the same technique to separate the words in a given string and determine and print the frequency of these words.

 
by Dinesh Thakur Category: Structure And Union

Consider the problem of comparison of two valid dates d1 and d2. There are three possible outcomes of this comparison: d1 == d2 (dates are equal), d1 > d2 (date d1 is greater, i.e., occurs after d2) and d1 < d2(date d1 is smaller, i.e., occurs before d2). Let us write a function that accepts two dates as structures dl and d2 of type struct date and returns 0 if the dates are equal, 1 if d1 is later than d2 and -1 if date dl is earlier than d2.

 
by Dinesh Thakur Category: Structure And Union

The computer has a main memory and CPU registers. The variables (as well as the program as a whole) are stored in memory. The modifier register tells the compiler that the variable in question should be, if possible, used in a CPU register.



 

Page 1 of 3



Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular