标题:哪位大神,谁能替小弟指点迷津
取消只看楼主
luoye1994
Rank: 2
等 级:论坛游民
帖 子:57
专家分:58
注 册:2015-6-29
结帖率:100%
已结贴  问题点数:100 回复次数:4 
哪位大神,谁能替小弟指点迷津
代码有点长,问题就显示了这个:undefined reference to!主要是函数调用的时候链接出现问题,谁能帮小弟解决
搜索更多相关主题的帖子: undefined reference 
2016-01-25 16:16
luoye1994
Rank: 2
等 级:论坛游民
帖 子:57
专家分:58
注 册:2015-6-29
得分:0 
代码如下:
#include <stdio.h>
#include <stdlib.h>

char *path = "C:\\Users\\Administrator\\Desktop\\11\\1.exe";
int getlength(char *path_1)
{
    FILE *pf = fopen(path_1 , "rb");
    if (pf == NULL)
    {
        return -1;
    }
    else
    {
        int length = 0;

        fseek(pf , 0 , SEEK_END);
        length = ftell(pf);

        return length;
    }
}

void getpath(char *newpath , int n)
{
    char **pathes;
    int i , j;

    pathes = malloc(sizeof(char *) * n);

    for(i = 0 ; i < n ; i++)
    {
        pathes[i] = malloc(sizeof(char) * 1024);
        sprintf(pathes[i] , "C:\\Users\\Administrator\\Desktop\\11\\1_%d.exe" , i+1);
    }

    FILE *pfr = fopen(newpath , "rb");
    if(pfr == NULL)
    {
        return;
    }
    else
    {
        int ALLlength = 0;
        ALLlength = getlength(newpath);

        if(ALLlength % n == 0)
        {
            for(i = 0 ; i < n ; i++)
            {
                FILE *pfw = fopen(pathes[i] , "wb");
                for(j = 0 ; j < ALLlength / n ; j++)
                {
                    fputc(fgetc(pfr) , pfw);
                }
                fclose(pfw);
            }
        }

        else
        {

            for(i = 0 ; i < (n - 1) ; i++)
            {
                FILE *pfw = fopen(pathes[i] , "wb");
                for(j = 0 ; j < ALLlength / (n - 1) ; j++)
                {
                    fputc(fgetc(pfr) , pfw);
                }
                fclose(pfw);
            }
            {
                FILE *pfw = fopen(pathes[n-1] , "wb");
                for(i = 0 ; i < ALLlength % (n-1) ; i++)
                {
                    fputc(fgetc(pfr) , pfw);
                }
                fclose(pfw);
            }

            fclose(pfr);







        }
    }


    void mesh(char *newpath_1 , int m)
    {


        char **pathes;
        int i , j;
        int length;

        pathes = malloc(sizeof(char *) * m);

        for(i = 0 ; i < m ; i++)
        {
            pathes[i] = malloc(sizeof(char) * 1024);
            sprintf(pathes[i] , "C:\\Users\\Administrator\\Desktop\\11\\1_%d.exe" , i+1);
        }

        FILE *pfw = fopen(newpath , "wb");
        for(i = 0 ; i < m ; i++)
        {
            length = getlength(pathes[i]);

            if(length == -1)
            {
                return;
            }
            else
            {
                FILE *pfr = fopen(pathes[i] , "rb");
                for(j = 0 ; j < length ; j++)
                {
                    fputc(fgetc(pfr) , pfw);
                }
                fclose(pfr);
            }
            fclose(pfw);
        }




    }



}

void main()
{
    int sum;
    char *pathss = "C:\\Users\\Administrator\\Desktop\\11\\abc.exe";
    scanf("%d" , &sum);
 //   getpath(path , sum);
    mesh(pathss , sum);
    system("pause");
}
不同颜色的部分是错误的部分
2016-01-25 16:18
luoye1994
Rank: 2
等 级:论坛游民
帖 子:57
专家分:58
注 册:2015-6-29
得分:0 
回复 3楼 wmf2014
把pathes 强制转换之后会出现不兼容的赋值!
2016-01-25 17:44
luoye1994
Rank: 2
等 级:论坛游民
帖 子:57
专家分:58
注 册:2015-6-29
得分:0 
回复 3楼 wmf2014
还是很感谢你,我主要是括号那边出问题了!但是一时半会找不出错误,着急了
2016-01-25 17:47
luoye1994
Rank: 2
等 级:论坛游民
帖 子:57
专家分:58
注 册:2015-6-29
得分:0 
回复 5楼 wmf2014
为什么用vc 6.0 编译,可以编译成功但是输入要分的组数,就直接终止程序了
2016-01-25 17:57



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




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

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