#include<stdio.h>
#include<malloc.h>
#define a 10
typedef struct
{
int* data;
int length;
int Maxsize;
}SqeList;
int main()
{
SqeList L;
Insert(L);
return 0;
}
void Insert(SqeList& L)
{
L.data = (int*)malloc(a * sizeof(int));
L.length = 0;
L.Maxsize = 10;
}
uj5u.com熱心網友回復:
函式寫在主函式之后,都必須先生命函式原型。uj5u.com熱心網友回復:
函式宣告要在前,修改如下,供參考:#include<stdio.h>
#include<malloc.h>
#define a 10
typedef struct
{
int* data;
int length;
int Maxsize;
}SqeList;
void Insert(SqeList& L);//函式宣告在前
int main()
{
SqeList L;
Insert(L);//呼叫在后
return 0;
}
void Insert(SqeList& L)
{
L.data = (int*)malloc(a * sizeof(int));
L.length = 0;
L.Maxsize = 10;
}
uj5u.com熱心網友回復:
呼叫的函式在main函式之后的話需要宣告,之前則不用uj5u.com熱心網友回復:
#include<stdio.h>
#include<malloc.h>
#define MAX_SIZE 10
typedef struct
{
int* data;
int length;
int Maxsize;
}SqeList;
void Insert(SqeList& L);
int main()
{
SqeList L;
Insert(L);
return 0;
}
void Insert(SqeList& L)
{
L.data = (int*)malloc(MAX_SIZE * sizeof(int));
L.length = 0;
//L.Maxsize = 10;
L.Maxsize = MAX_SIZE;
}
供參考~
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/260729.html
標籤:C語言
上一篇:OpenCV打開視頻檔案問題
下一篇:關于gets()函式的回傳值
