file1:
there are 20000000000000 Rows in file1.Code:12E3F 1E34F 34EF5 ......
Can I store the file into 20000000000000*5 array ?
if not , how to implement it ?
file1:
there are 20000000000000 Rows in file1.Code:12E3F 1E34F 34EF5 ......
Can I store the file into 20000000000000*5 array ?
if not , how to implement it ?
By 'store', I assume you mean 'load into memory all at the same time', which leads me to ask: Why?
To answer your question: No, you can't make a true array that size. You'll run out of stack space. Your best shot is to dynamically allocate it with something like malloc. But again, you're probably out of luck unless you're on a 64 bit OS. 100000000000000 is too big to fit in a 32bit data type.
Quzah.
Hope is the first step on the road to disappointment.
this is my test program . why error ?Code:#include "stdlib.h" #include "stdio.h" #include "string.h" int main(int argc,char *argv[]) { char **p = (char **) malloc ( 50*sizeof(char)); FILE *fr = fopen("test.data","r"); char a; int i = 0; int m = 0; int n = 0; while ( fscanf(fr, "%c", &a ) == 1 ) { //char line[10]; //fgets(line,10,fr); if ( a == '\n' ) { m = 0; n++; } else { *(*(p+n)+m) = a; m++; } } return 0; }
Why are you using a pointer to a pointer? If you want to pretend it's a 2D array, then you need two steps:You are using fscanf to read a single character. That's not its best suit. Why not just use fgetc if you only want one character?Code:char **p; p = malloc( sizeof( char * ) * numberofrows ); for( x = 0; x < numberofrows; x++ ) p[ x ] = malloc( numberofcolumnsperrow );
But to answer your question: it's crashing because you're not allocating memory right. See point one again.
Edit: And to go along with what Elysia said, stop making new threads for the same exact topic. You have like four now.
Quzah.
Hope is the first step on the road to disappointment.