|
|
|
@ -26,16 +26,20 @@ int main(void) { |
|
|
|
|
int cols; |
|
|
|
|
|
|
|
|
|
while (fgets(strBuffer, sizeof strBuffer, ptrFile) != 0) { |
|
|
|
|
// Grow the buffer when needed
|
|
|
|
|
if (sizeBufferUsed == sizeBufferTotal) { |
|
|
|
|
sizeBufferTotal *= GROWTH_FACTOR; |
|
|
|
|
arrNumbers = my_realloc(arrNumbers, sizeBufferTotal * sizeof(int)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// store the pointer
|
|
|
|
|
ptrBuffer = strBuffer; |
|
|
|
|
cols = 0; |
|
|
|
|
// Read untill newline
|
|
|
|
|
while (*ptrBuffer != '\n') { |
|
|
|
|
// Convert string to base 10
|
|
|
|
|
numValue = strtol(ptrBuffer, &ptrBuffer, 10); |
|
|
|
|
// Store the number read in memory
|
|
|
|
|
arrNumbers[sizeBufferUsed++] = numValue; |
|
|
|
|
cols++; |
|
|
|
|
} |
|
|
|
|