#define _crt_secure_no_warnings#include <stdio.h> #include <stdlib.h> #include <string.h> #include <Windows.h> #include <memory.h> #define PATH "e:\\ cluttered test\\ memory Big Data Model \\1e~001.txt" char **g_pp;int IMAX = 8435714;//identifies how many lines int jmax = 20027;//identifies the widest int getjmax () {int width =-1; File *PF = fopen (path, "R");//Read files open path if (PF = = NULL) {printf ("File open Failed");} Else{while (!feof (PF)) {char readstr[30000] = {0};fgets (readstr, 30000, PF);//read one line of readstr[29999] = ' + ';//end of string int St Rlength = strlen (READSTR), if (Strlength > width) {width = strlength;}} Fclose (PF);//close}return width;} int Getimax () {int hang =-1; File *PF = fopen (path, "R");//Read files open path if (PF = = NULL) {hang = -1;printf ("File open Failed");} Else{while (!feof (PF)) {char readstr[1024] = {0};fgets (readstr, 1024x768, pf);//read a row of hang++;} Fclose (PF);//close}return hang;} void LoadFromFile () {g_pp = (char * *) malloc (sizeof (char*) *imax);//allocation pointer array how many rows memset (g_pp, ' n ', sizeof (char*) *imax); File *PF = fopen (path, "R"), if (PF = = NULL) {printf ("File open Failed"), return; Else{for (int i = 0; i < imax;i++) {char str[1024] = {0};fgets (str, 1024x768, PF);//read by line str[1023] = ' strlength '; N (str), if (Strlength <) {G_pp[i] = malloc (sizeof (char) * (Strlength + 1)), strcpy (G_pp[i], str),//Copy to allocated memory}}fclose ( PF);p rintf ("Loading complete \ n");}} void Search (char *str) {if (g_pp! = null) {for (int i = 0; i < IMAX; i++) {if (G_pp[i]! = NULL) {Char *p = strstr (G_pp[i], STR);//Find return address, otherwise return Nullif (P! = NULL) {puts (g_pp[i]);//print}}}}}void main () {loadfromfile (); while (1) {char str[100] = {0}; scanf ("%s", str); search (str);//Retrieve}system ("pause");}
Big Data memory model (level two pointers)