This is about C Programming.
Q.
Implement a function ‘get_numbers’ and call it in the mainfunction.
The function should read one line of the file which includesintegers,
and return an integer pointer for the integers.
– do not assume the length of array.
-read one number and use it to allocate memory space inget_numbers.
-free the memory space in the main function
I wrote some codes for the question, but it doesn’t workproplerly…
please fix my code to make it work properly.
#include <stdio.h>
#include <stdlib.h>
int *get_numbers(char filename[],int* line);
int main()
{
int i =0;
int *linep = NULL;
int numArr[] = {0};
linep =get_numbers(“hw4_2_input.txt”,linep);
while(linep[i]!=”n”){
numArr[i] = linep[i];
if(linep == “n”){
putchar(“n”);
}else{
printf(“%d “, numArr[i]);
}
i++;
}
PayPal Gateway not configured
PayPal Gateway not configured