Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
506 B
5
Indexable
Never
#include <stdio.h>
#include <unistd.h>

int main(void)
{
        /*Buffer whose address will be passed as argument to getline()*/
        char *buffer;
        size_t n;
        ssize_t bytes_read;

        n = 0;
        buffer = NULL;
        /*printing the prompt for the user to enter something*/
        printf("$ ");
        bytes_read = getline(&buffer, &n, stdin);
        if (bytes_read == -1)
                perror("Error");
        printf("%s", buffer);
        return (0);
}
Leave a Comment