Working with big data, programming implementation examples

Source: Internet
Author: User

#define _crt_secure_no_warnings#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <process.h>//multithreading char g_path[200] = "i:\\baiduyundownload\\1 QQ envelope \\1E5-10 bit \\QQ envelope. txt"; #define N 84357584char str[100] = {0};char **g_pall = null;//Two-level pointer stores the address of the first-level pointer array int getn () {FILE *PFR = fopen (G_path, "R") ; if (PFR = = NULL) {return-1;} Else{int i = 0;while (!feof (PFR)) {char strbuffer[256] = {0};fgets (strbuffer, N, PFR);//read one line of i++;} Fclose (PFR);//close file return i;}} void Eatn (char *str) {while (*str! = ') ') {if (*str = = ' \ n ') {*str = '} ';} str++;}} void Init () {G_pall = (char * *) malloc (sizeof (char *) *n);//dynamically assigns an array of pointers memset (G_pall, ' + ', sizeof (char *) *n); FILE *PFR = fopen (G_path, "R"), if (PFR = = NULL) {printf ("Initialization failed"); return;} else{for (int i = 0; i < N; i++) {char strbuffer[79] = {0};fgets (strbuffer,, PFR);//reads a row of//printf ("%s,%d", Strbuffe R,strlen (Strbuffer)); Eatn (Strbuffer);//printf ("%s,%d", Strbuffer, strlen (Strbuffer)); int length = strlen (strbuffER);//To obtain the length if (length! = 0) {G_pall[i] = malloc (sizeof (char) * (length + 1));//each pointer allocates memory if (g_pall[i] = = NULL) {printf ("\ Nfail ");} strcpy (G_pall[i], strbuffer);//Copy String//printf ("\n%s", G_pall[i]);//print result}}fclose (PFR);//Close File}}void search (char *str) {Int J = 0;for (int i = 0; i < N-1; i++) {if (G_pall[i]!=null) {char *p = strstr (g_pall[i], str);//query if (P! = NULL) {j + +; printf ("\n%s", G_pall[i]);//Print Results}}}printf ("\nj=%d", j);//print slower than query}void main () {//printf ("%d", Getn ()), init ();p rintf ("Already loaded complete"); while (1) {//time_t start, end;time (&start);//int i = 0;//scanf ("%d", &i);//printf ("\n%s", G_pall[i] ); scanf ("%s", str), search (str), Time (&end);p rintf ("\ n altogether%d S", (unsigned int) (End-start));} System ("Pause");}

Working with big data, programming implementation examples

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.