C: stdin and std* errs

Posted by user355926 on Stack Overflow See other posts from Stack Overflow or by user355926
Published on 2010-06-05T23:23:53Z Indexed on 2010/06/05 23:32 UTC
Read the original article Hit count: 168

Filed under:
|

I want to my manipulate Stdin, then Std* but some errs:

$ gcc testFd.c                                                                 
testFd.c:9: error: initializer element is not constant
testFd.c:9: warning: data definition has no type or storage class
testFd.c:10: error: redefinition of `fd'
testFd.c:9: error: `fd' previously defined here
testFd.c:10: error: `mode' undeclared here (not in a function)
testFd.c:10: error: initializer element is not constant
testFd.c:10: warning: data definition has no type or storage class
testFd.c:12: error: syntax error before string constant
$ cat testFd.c                                                                 
#include <stdio.h>
#include <sys/ioctl.h>

int STDIN_FILENO = 1;
// I want to access typed 
// Shell commands, dunno about the value:
unsigned long F_DUPFD;

fd = fcntl(STDIN_FILENO, F_DUPFD, 0);
fd = open("/dev/fd/0", mode);

printf("STDIN = %s", fd);

© Stack Overflow or respective owner

Related posts about c

    Related posts about descriptors