首页 > 解决方案 > 函数'fopen_s'的隐式声明[-Wimplicit-function-declaration] FILE *f = fopen_s(stdin);

问题描述

嗨,我的编译器出现以下错误,请帮忙!

从编译器:main.c:在函数'main'中:main.c:25:13:警告:函数的隐式声明

fopen_s' [-Wimplicit-function-declaration] 文件 *f = fopen_s(stdin); ^~~~~~~

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
        //FILE *f ;

     int main(int argc, char **argv) {
     int charCount = 0;
     int wordCount = 0;
     int lineCount = 0;
     int doChar    = 0;
     int doWord    = 0;
     int doLine    = 0;
     int inWord    = 0;
     int c         = 0;
     char *fileName = 0;
     FILE *f = fopen_s(stdin);

// prompt user to enter filename
        printf("Please enter a filename: \n");
//  fgetwc(f);
//loop
        while (argv++, -- argc) {
        if (!strcmp(*argv, "-c"))       doChar = 1;
        else if (!strcmp(*argv, "-w"))  doWord = 1;
        else if ( !strcmp(*argv, "-l")) doLine = 1;
        else if (!( f = fopen((fileName = *argv),"r"))) {
            printf("Usage: wc [-1] [-w] [-c]\n");
            return 1;
        }
    }
    if (!(doChar || doWord || doLine)) {
        doChar = doWord = doLine= 1;
    }
    while(EOF !=( c= fgetc(f)))
    {
        charCount++;
    }
        if (c == '\n') {
             lineCount++;
         }
        if (!isspace(c)) {
            if (!inWord){
                {inWord = 1; wordCount++;}
            }
            else {
                inWord = 0;
            }
        }
    if (doLine){
         printf("%8d\n",lineCount);
     }
    if (doWord){
        printf("%8d\n", wordCount);
    }
    if(doChar){
        printf("%8d\n",charCount );
    }
    if (fileName) {
        printf(" %s\n",fileName);
    }
    printf("\n" );
}

标签: ccompiler-errorsfopen

解决方案


推荐阅读