Computer Programming
C Programming
C++ Programming

What is a structure in C programming?

User Avatar
Wiki User
2008-08-02 16:38:04

A rectangle might have a width, a height, a color, and a

fill

pattern. C lets us organize these four items into one group

called a

structure. Example

struct rectangle {

int width; /* Width of rectangle in pixels */

int height; /* Height of rectangle in pixels */

color_type color; /* Color of the rectangle */

fill_type fill; /* Fill pattern */

}; Another example suppose we want to record

the time a runner completes each lap of a four -lap race. We

define a structure to

store the time:

struct time {

int hour; /* hour (24 hour clock ) */

int minute; /* 0-59 */

int second; /* 0-59 */

}; A rectangle might have a width, a height, a color, and a

fill

pattern. C lets us organize these four items into one group

called a

structure. Example

struct rectangle {

int width; /* Width of rectangle in pixels */

int height; /* Height of rectangle in pixels */

color_type color; /* Color of the rectangle */

fill_type fill; /* Fill pattern */

}; Another example suppose we want to record

the time a runner completes each lap of a four -lap race. We

define a structure to

store the time:

struct time {

int hour; /* hour (24 hour clock ) */

int minute; /* 0-59 */

int second; /* 0-59 */

};


Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.