我想关闭与句柄关联的文件,但我收到编译器的警告:
main.c:96:2:警告:隐式声明函数'close'[-Wimplicit-function-declaration]
这是我的代码来源:
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
...
int handle;
...
handle = open(path, flags, mode);
...
close(handle);
Run Code Online (Sandbox Code Playgroud)
为什么我收到这个警告,我该如何解决?
这是整个代码源:
#include "header.h"
// Prototypes
void menu(char choix);
void creer();
void lire();
int ouvrir(char *path, int flags, mode_t mode);
int main(int argc, char **argv)
{
char choix;
int c;
printf(PROGRAME_NAME, CYAN_BOLD,RESETCOLOR, CYAN_BOLD_BG, RESETCOLOR, CYAN_BOLD, RESETCOLOR);
do{
//printf("\e[1;1H\e[2J");
printf("\n\n%sMenu :%s\n", RED_BOLD, RESETCOLOR);
printf("\t(%sC%s)réer un fichier\n", RED_BOLD, RESETCOLOR);
printf("\t(%sL%s)ire un fichier\n", RED_BOLD, RESETCOLOR);
printf("\t(%sE%s)crire …
Run Code Online (Sandbox Code Playgroud) 我想创建一个简单的java类,使用main方法,但是当我编译我的代码时,我收到此错误消息:
错误:在类errors.TestErrors中找不到主要方法,请将main方法定义为:public static void main(String [] args)
这是源代码:
package errors;
public class TestErrors {
public static void main(String[] args){
System.out.println("hello");
}
}
Run Code Online (Sandbox Code Playgroud)
为什么我看到这个错误,因为你可以注意到我的alreader声明了主要的方法!
我正在创建一个程序C
,我在我的代码中有这一行:
scanf("%s", &path);
Run Code Online (Sandbox Code Playgroud)
当我编译源文件时,我收到此警告:
main.c:84:2: warning: format ‘%s’ expects argument of type ‘char *’, but argument 2 has type ‘char (*)[64]’ [-Wformat]
Run Code Online (Sandbox Code Playgroud)
这是path
变量的声明:
char path[64];
Run Code Online (Sandbox Code Playgroud)
为什么我看到这个错误?我该如何解决?