#include <stdio.h> int main ( int nNumberofArguments, char* apszArgument [] ) { int nReturncode = 0 ; int* pnStorage = NULL ; int* pnTmp = NULL ; int nNumberofelements = 0 ; int nNumberofreadfields = 0 ; int nCounter = 0 ; int nInput = 0 ; while ((nReturncode == 0) && ((nNumberofreadfields = scanf("%d", &nInput)) == 1)) { nNumberofelements++ ; if (pnStorage != NULL) pnTmp = pnStorage ; if ((pnStorage = (int *) malloc (sizeof (int) * nNumberofelements)) != NULL) { nCounter = 0 ; if (pnStorage != NULL) for (nCounter = 0 ; nCounter < (nNumberofelements - 1) ; nCounter++) pnStorage[nCounter] = pnTmp[nCounter] ; pnStorage[nCounter] = nInput ; free (pnTmp) ; } else { fprintf (stderr, "Not enough memory\n") ; nReturncode = 1 ; } } if (nReturncode == 0) { for ( nCounter = 0 ; nCounter < nNumberofelements ; nCounter += 1 ) fprintf (stdout,"pnStorage [%d] : %d\n", nCounter, pnStorage [nCounter]) ; fprintf (stdout, "=====================\nNumber of elements : %d\n", nNumberofelements) ; } free (pnStorage) ; return nReturncode ; }
-- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]