zoukankan      html  css  js  c++  java
  • Run-Time Check Failure #2

     
    
    代码如下  :
    
    // EOF范例.cpp: 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      char ch;
      FILE *f;
      char a[300];
      printf("enter the file name:");
      scanf("%s", a);
      f = fopen(a,"r");
    
    
      if (f == NULL)
      {
        printf("failed to open file. ");
        exit(1);
      }
      while (( ch=getc(f)) != EOF)
      {
        putchar(ch);
      }
      fclose(f);
      getchar();
      return 0;
    }
    
     

    解决方法:项目属性页(Alt+F7) -> 配置属性 -> C++ -> 代码生成 -> 基本运行时检查 默认值

    但是也不能解决 疑问了  我就将输入的.txt文件  格式设置为 ANSI  而不是utf-8 或unicode  这时就正确了     

    另外在使用scanf 与fopen 函数时报错 解决方法如下

    右键工程名–>属性–>C/C++–>预处理器–>预处理器定义,编辑右边输入框加入: 
    _CRT_SECURE_NO_WARNINGS 

  • 相关阅读:
    子网掩码
    子网
    ARP
    IPv6
    Host-Only(仅主机模式)
    NAT(地址转换模式)
    Bridged(桥接模式)
    VMware配置网络/Linux
    three months timestamp
    spring cloud禁止输出日志:ConfigClusterResolver : Resolving eureka endpoints via configuration
  • 原文地址:https://www.cnblogs.com/zhengbao/p/8851162.html
Copyright © 2011-2022 走看看