当前位置: 技术问答>linux和unix
哪位linux高手帮我修改下下面的C程序,错误提示我已经贴出来,谢谢。
来源: 互联网 发布时间:2016-10-31
本文导语: /* [root@localhost tellfile]# ls aa makefile tell tell.c [root@localhost tellfile]# ./tell please input the file name : aa Segmentation fault [root@localhost tellfile]# */ #include #include #include #include #include #include //int stat(const cha...
/*
[root@localhost tellfile]# ls
aa makefile tell tell.c
[root@localhost tellfile]# ./tell
please input the file name :
aa
Segmentation fault
[root@localhost tellfile]#
*/
#include
#include
#include
#include
#include
#include
//int stat(const char *path, struct stat *buf);
//int fstat(int fd, struct stat *buf);
// open(const char *pathname, int flags);
// open(const char *pathname, int flags, mode_t mode);
int main()
{
char *filename;
int fd;
struct stat buf;
printf("please input the file name :n");
scanf("%s",filename);
if((fd = open(filename,O_RDONLY || O_WRONLY || O_CREAT))
[root@localhost tellfile]# ls
aa makefile tell tell.c
[root@localhost tellfile]# ./tell
please input the file name :
aa
Segmentation fault
[root@localhost tellfile]#
*/
#include
#include
#include
#include
#include
#include
//int stat(const char *path, struct stat *buf);
//int fstat(int fd, struct stat *buf);
// open(const char *pathname, int flags);
// open(const char *pathname, int flags, mode_t mode);
int main()
{
char *filename;
int fd;
struct stat buf;
printf("please input the file name :n");
scanf("%s",filename);
if((fd = open(filename,O_RDONLY || O_WRONLY || O_CREAT))