Writing data read with read () to int array in C
问题 I have a file with numbers on each line. I am trying to write the data read from the file to the int array with the read () function. I can read the file and print it to the terminal. How can i get the numbers i read into arr array ? Here is my code #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> int main() { int len, fd,arr[10000],i=0; fd = open("1.txt", O_RDONLY); if (fd >= 0) { while(read(fd, &len, sizeof(int)) > 0){ write(1, &len, sizeof