我无法让它发挥作用! 抛出错误。
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
size_t NbOfElmts;
float * Weights;
int * Areas;
} ListOfCoeff;
typedef struct
{
size_t NbOfElmts;
ListOfCoeff * Elmts;
} SetOfListsOfCoeff;
int main( int argc, const char* argv[] ){
SetOfListsOfCoeff * theList;
int N = 10;
float *A = malloc( N * sizeof(*A) );
for ( int i = 0; i < N; i++)
A[ i ] = i;
for ( int i = 0; i < N; i++ )
( (theList[ i ].Elmts)->Weights)[ i ] = A[ i ];
for ( int i = 0; i < N; i++)
printf("\n List = %f", ( (theList[ i ].Elmts)->Weights)[ i ] );
return 0;
}
行中的问题:
( (theList[ i ].Elmts)->Weights)[ i ] = A[ i ];
答案 0 :(得分:2)
您尚未为列表分配任何内存。