小编use*_*861的帖子

函数'close'的隐式声明

我想关闭与句柄关联的文件,但我收到编译器的警告:

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)

为什么我收到这个警告,我该如何解决?

这是整个代码源:

main.c中

#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)

c

30
推荐指数
1
解决办法
6万
查看次数

即使我已经宣布它,也找不到主要方法

我想创建一个简单的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声明了主要的方法!

java

7
推荐指数
1
解决办法
2万
查看次数

格式'%s'需要'char*'类型的参数,但参数2的类型为'char(*)[64]

我正在创建一个程序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)

为什么我看到这个错误?我该如何解决?

c

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

c ×2

java ×1