In your code the sizeof(readbuffer)
is equal to 4 in the following snippet., so it reads 4 bytes max.
void readStringFromFile (int file, char * readbuffer) {
int nbytes = read(file, readbuffer, sizeof(readbuffer));
readbuffer[nbytes] = 0;
}
You can send the size of the buffer as another parameter, giving:
void readStringFromFile (int file, char * readbuffer, int maxsize) {
int nbytes = read(file, readbuffer, maxsize);
readbuffer[nbytes] = 0;
}
and invoke it with:
readStringFromFile(fd[0], readbuffer, sizeof(readbuffer));