[英]Doesn't GCC recognize the function "read"?
I was solving the pwnable.kr's fd problem and wondered how does the fd.c code works.我正在解决 pwnable.kr 的 fd 问题,想知道 fd.c 代码是如何工作的。 So I copied the c code and I put it on GCC to see how it works.
所以我复制了 c 代码并将其放在 GCC 上,看看它是如何工作的。 And it has an error says: "implicit declaration of function 'read'; did you mean 'fread'?"
它有一个错误说:“ function 'read'的隐式声明;你的意思是'fread'吗?” Does GCC not recognize the Read function on C?
GCC 是否无法识别 C 上的 Read function?
The code looks like:代码如下所示:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char buf[32];
int main(int argc, char* argv[], char* envp[]){
if(argc<2){
printf("pass argv[1] a number\n");
return 0;
}
int fd = atoi( argv[1] ) - 0x1234;
int len = 0;
len = read(fd, buf, 32);
if(!strcmp("LETMEWIN\n", buf)){
printf("good job :)\n");
system("/bin/cat flag");
exit(0);
}
printf("learn about Linux file IO\n");
return 0;
}
Thank you谢谢
From the man page ( man 2 read
):从手册页(
man 2 read
):
NAME
姓名
read - read from a file descriptor
read - 从文件描述符中读取
SYNOPSIS
概要
#include <unistd.h>
#include <unistd.h>
ssize_t read(int fd, void *buf, size_t count);
ssize_t read(int fd, void *buf, size_t count);
You must include unistd.h
and the warning will go away.您必须包含
unistd.h
并且警告将 go 消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.