Hi all,
I am trying to use fgets to read input from user. The funtion works fine enough, but according to the spec. fgets should only read until number of char are read according to length sent (or newline or eof). So my understanding is if i do the following:
This should only read 5 characters from keybord and then print the buffer? But it dosnt. The fgets function keeps on going until i press enter. Am i missing something here?Code:#include <stdio.h>
#include <iostream.h>
int main(void){
char buffer[100];
while(1){
fgets(buffer, 5, stdin); // read 5 char
printf(buffer); // print buffer to test
}
}
G'n'R