Does putchar remove the item from array?

Does putchar remove the item from buffer when it prints to the outstream? The reason I ask is because in below example, each time while loop executes in main, obviously we want to put new characters in buffer and have none already in it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <stdio.h>



#define MINLENGTH 81



int readbuff(char *buffer) {

    size_t i=0;

    int c;

    while (i < MINLENGTH) {

        c = getchar();

        if (c == EOF) return -1;

        if (c == '\n') return 0;

        buffer[i++] = c;

    }

    return 1;

}



int copyline(char *buffer) {

    size_t i;

    int c;

    int status = 1;

    for(i=0; i<MINLENGTH; i++)

        putchar(buffer[i]);

    while(status == 1) {

        c = getchar();

        if (c == EOF)

            status = -1;

        else if (c == '\n')

            status = 0;

        else

            putchar(c);

    }

    putchar('\n');

    return status;

}



int main(void) {

    char buffer[MINLENGTH];

    int status = 0;

    while (status != -1) {

        status = readbuff(buffer);

        if (status == 1)

            status = copyline(buffer);

    }

    return 0;

}
Topic archived. No new replies allowed.