C read() adds strange characters

Viewed 2334

I've got such code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
int main(){
    char input[100];
    while(1){
        int k = read(0,input,100);
        if(k == 0) break;
        write(1,input,strlen(input));
    }
}

And after putting some lines on stdin, like:
example example
example example
...

it it's not normally displayed. Instead, near the ends of input block there are always some strange characters. Could someone explain that?

2 Answers
Related