哪位大神,谁能替小弟指点迷津
代码有点长,问题就显示了这个:undefined reference to!主要是函数调用的时候链接出现问题,谁能帮小弟解决
代码如下:
#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");
}
不同颜色的部分是错误的部分