You need parentheses in there (now fixed in the question), and the second argument to open()
is not a string:
#include <fcntl.h>
int fd;
if ((fd = open("/proc/test", O_RDONLY)) < 0)
perror("open");
I'm not convinced it was a good idea to create a file of any sort in the /proc
file system. In fact, I'm a bit surprised you were allowed to. If you are learning to program as root
, I hope you have good backups.