Microsoft KB Archive/75602

= How to initialize an array of structures within a Microsoft C program =

Article ID: 75602

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft C/C++ Professional Development System 7.0a
 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q75602





SUMMARY
The code fragment below demonstrates how to initialize an array of structures within a Microsoft C program. Each element is grouped within brackets, and the elements are separated by commas. The initialization of the array rgttype shows how to initialize a structure within a structure within an array of structures.

Sample Code
/* Compile options needed: none

struct stype { int a;  int b;   int c; };

struct ttype { int alpha; struct stype beta; };

/*  a,    b,   c  */ struct stype rgstype[2] = { {8,  9,   10}, \ {15, 16,  17} };

/* alpha     beta     */ struct ttype rgttype[2] = { {{1},  {2,3,4}}, \ {{5},  {6,7,8}}  };

Keywords: kbhowto kbfile kblangc kbcode KB75602

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.