Big Data memory model (level two pointers)

Source: Internet
Author: User

#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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.