C Programming/Pointers and arrays - Wikibooks, open books for an open world

C Programming/Pointers and arrays - Wikibooks, open books for an open world

float KrazyFunction( struct MyStruct *parm1, int p1size, int bb )
{
int ix; //declaring an integer variable//
for (ix=0; ix<p1size; ix++) {
if (parm1[ix].m_aNumber == bb )
return parm1[ix].num2;
}
return 0.0f;
}

/* ... */
struct MyStruct myArray[4];
#define MY_ARRAY_SIZE (sizeof(myArray)/sizeof(*myArray))
float v3;
struct MyStruct *secondArray;
int someSize;
int ix;
/* initialization of myArray ... */
v3 = KrazyFunction( myArray, MY_ARRAY_SIZE, 4 );
/* ... */
secondArray = calloc( someSize, sizeof(myArray) );
for (ix=0; ix<someSize; ix++) {
secondArray[ix].m_aNumber = ix *2;
secondArray[ix].num2 = .304 * ix * ix;
}

你可能感兴趣的:(programming)