- index.h
1 #define _CRT_SECURE_NO_WARNINGS 2 #include<stdio.h> 3 #include<stdlib.h> 4 #define N 10000000 5 6 struct index 7 { 8 int *pindex; 9 int length; 10 }; 11 12 char **g_pp;//保存指针数组 13 char filepath[256]; 14 char sortpath[256]; 15 char indexpath[256]; 16 struct index allindex;//索引 17 18 int getN();//函数声明 19 void eatg(char *str); 20 void eatN(char *str);
- index.c
1 #include"index.h" 2 3 char **g_pp = NULL;//保存指针数组 4 char filepath[256] = { 0 }; 5 char sortpath[256] = { 0 }; 6 char indexpath[256] = { 0 }; 7 struct index allindex = { 0 };//索引 8 9 int getN() 10 { 11 FILE *pf = fopen("file.txt", "r"); 12 if (pf == NULL) 13 { 14 return -1; 15 } 16 else 17 { 18 int i = 0; 19 while (!feof(pf)) 20 { 21 char str[50] = { 0 }; 22 fgets(str, 50, pf);//读取 23 i++; 24 } 25 fclose(pf); 26 return i; 27 28 } 29 } 30 void eatg(char *str) 31 { 32 while (*str != '