「main」で定義された構造体配列にメモリを割り当てる関数を作成しようとしています。問題は、私の関数が構造を認識していないようです。次のコードの何が問題になっていますか?
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct typecomplex { float r; float i; } complex;
complex *myfunction(int n);
int main (int argc, char *argv[]) {
complex *result = myfunction(1000);
exit(0);
}
...そして別のファイルで...
struct complex *myfunction(int n) {
complex *result = (complex *)malloc(n*sizeof(*complex));
if(result==NULL) return(NULL);
else return(result);
}