How do I use a char
array to be the data storage for a FILE
stream?
char buffer[max_len];
FILE *fp = fopen(<I want to use data in buffer variable as file data>, "r");
The goal is to have data ready in fp
for the following behavior:
execl("/bin/cat", "cat", fp, (char *)NULL);
Additionally, when using fmemopen
(as suggested):
char buf[] = "hello";
FILE *fp = fmemopen(buf, strlen(buf), "w");
execl("/usr/bin/echo", "echo", fp, (char *)NULL);
I get mangled output..