Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int main(){
- char *matriz;
- matriz = ( char * ) malloc ( 1000000 );//1 milhão de bytes ou 1MB
- int i;
- FILE *arq = fopen("Meuarquivo.txt", "r" );//113MB
- if ( arq == NULL ){
- textcolor(YELLOW);gotoxy(26,12);
- printf("Problemas na abertura do arquivo ");
- getche();
- return (0);
- }
- textcolor(WHITE);
- for ( i = 0; i < 64443; i++ ) {//Só lê e imprime até esta linha 64443.
- fgets ( matriz, 255, arq );
- printf("%d %s ", i, matriz );
- }
- //Tentei realocar mais memória más não adianta, a contagem
- //das linhas prossegue, más sai vazio, não imprime mais nada do arquivo
- //tentei resetar a matriz de várias forma, para preencher com dados
- //a partir da linha 64443 más também não resolveu.
- matriz = ( char * ) realloc ( matriz, 2000000 );//2 milhões de bytes ou 2MB
- textcolor(WHITE);
- for ( i = 64443; i < 128000; i++ ) {
- fgets ( matriz, 255, arq );
- printf("%d %s ", i, matriz );
- }
- fclose(arq);
- getche();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement