note 55673 added to function.fscanf

From: Date: Wed, 10 Aug 2005 11:31:19 +0000
Subject: note 55673 added to function.fscanf
Groups: php.notes 
Request: Send a blank email to php-notes+get-93364@lists.php.net to get a copy of this message
Here is my code to read a line by line from a file { long lFileSize,i; int iCount = 0; int iInitialBlockSize=1000; int p; FILE *pFilePt; g_szFileRetrieved = (char **)calloc( iInitialBlockSize, sizeof(char *) ); pFilePt = fopen (szDAT_FileName, "rb"); while( !(pFilePt->state.eof) ) { g_szFileRetrieved[iCount] = (char *)calloc(500, sizeof(char)); i = fscanf (pFilePt, "%[^\n]\n", g_szFileRetrieved[iCount]); printf("i = %i", i); printf("g_szFileRetrieved[%i] --> %s\n", iCount, g_szFileRetrieved[iCount] ); if( i==0||i==-1 ) { printf("\n\nAn error occurred during file loading !!\n\n"); break; } else iCount++; if(iCount>=iInitialBlockSize) { iInitialBlockSize = iInitialBlockSize + 1000; g_szFileRetrieved = realloc (g_szFileRetrieved, sizeof(char **)*iInitialBlockSize); } } } ---- Manual Page -- http://www.php.net/manual/en/function.fscanf.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55673 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55673&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55673&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93364) next »