Question

I've asked a question regarding the theoretical aspect of this code a couple of hours ago. Now I understand everything, however, that code simply gives no output. Here's the link to the code on http://ideone.com/LWMC5

Code:

#include <stdio.h>
#include <unistd.h> /* changed from "syscalls.h" it was not working */
/* changed the name intentionally */
int main(void)
{

    static char buf[BUFSIZ];
    static char *bufp = buf; 
    static int n = 0;
    if (n == 0) {            /* buffer is empty */
        n = read(0, buf, sizeof buf);
        bufp = buf;          
    }
    return (--n >= 0) ? (unsigned char) *bufp++ : EOF; 
}

What should I do/add to produce output?

Was it helpful?

Solution

I don't understand what did you expect as output, to print something on the screen, you need to use something like printf.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top