标题:编程中编译错误问题 [Error] ld returned 1 exit status
只看楼主
初hm
Rank: 1
等 级:新手上路
帖 子:2
专家分:4
注 册:2019-5-28
 问题点数:0 回复次数:1 
编程中编译错误问题 [Error] ld returned 1 exit status
# include <stdlib.h>
# include <iostream>
using namespace std;

//设计可利用空间表的结构
typedef struct FreeMenory
{
    int Size;
    int BeginAdd;
    int EndAdd;
    struct FreeMenory *pre;
    struct FreeMenory *next;
}FreeMenory;

//用边界标识法实现内存的分配
void InitialFreeMenory(FreeMenory *L)
{
    void output(FreeMenory *L);
    int Maxsize;
    int BeginAdd;
    int EndAdd;
    int flag;
    int i;
    FreeMenory  *P;
    FreeMenory  *Follow;
    Follow=L;
    flag=0;
    i=1;
   
 again:    printf("Please input the Total Menory Size, input 0 to exit divide :\n");
    printf("totalsize :");
    scanf("%d",&Maxsize);
    if(Maxsize<0)
    {
        printf("errror:\n");
        goto again;
    }
    printf("please divide Menory :\n");
    while(1)
   {
again1:    printf("\n available size %d BeginAddress: ",i);
    scanf("%d",&BeginAdd);
    if(BeginAdd==0)
    break;
    if(BeginAdd<flag||BeginAdd>Maxsize)
    {
        printf("please input biger Address than previous EndAddress and smaller than Maxsize \n:");
        goto again1;
    }   
again2:    printf("\n available size %d EndAddress: ",i);
    scanf("%d",&EndAdd);
    if(EndAdd>Maxsize||EndAdd<BeginAdd)
    {
        printf("EndAddress must be small then MaxSize and larger than Beginadd:\n");
        goto again2;
    }
    P=(FreeMenory*)malloc(sizeof(FreeMenory));
    P->BeginAdd=BeginAdd;
    P->EndAdd=EndAdd;
    P->Size=EndAdd-BeginAdd+1;
    Follow->next=P;
    P->pre=Follow;
    P->next=NULL;
    Follow=P;
    flag=EndAdd;
    i++;
    }
    output(L);
}

int main()
{
    FreeMenory *L;
    L=(FreeMenory*)malloc(sizeof(FreeMenory));
    InitialFreeMenory(L);
   
}
搜索更多相关主题的帖子: exit int Size flag printf 
2019-05-28 17:26
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:0 
[Error] ld returned 1 exit status
说这句话有什么意义,你要说出哪里编译错误。比如
VC++编译报错为: unresolved external symbol "void __cdecl output(struct FreeMenory *)"
g++编译报错为:undefined reference to `output(FreeMenory*)'

这样别人才能知道,原来你申明了 void output(FreeMenory *L),但是却无实现。
2019-05-29 08:44



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494981-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028189 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved