Visual studio 2015 我能';t使用;fscanf";2019年

Visual studio 2015 我能';t使用;fscanf";2019年,visual-studio-2015,Visual Studio 2015,我在DEVC++中使用了“fscanf(f、%d、&a)”,它仍然可以工作。但我在VS2019中写了“fscanf”并出错 不要使用FSCAN。如果它不安全,不应该再使用,请使用FSCAN。C是一种古老的语言,因此它有许多不应该使用的、不能删除的粗枝大叶 //crt\u fscanf\u s.c //这个程序写的是格式化的 //将数据保存到文件中。然后,它使用fscanf //从文件中读回各种数据。 #包括 #包括 文件*流; 内部主(空) { 长l; 浮点数; chars[81]; 字符c;


我在DEVC++中使用了“fscanf(f、%d、&a)”,它仍然可以工作。但我在VS2019中写了“fscanf”并出错

不要使用FSCAN。如果它不安全,不应该再使用,请使用FSCAN。C是一种古老的语言,因此它有许多不应该使用的、不能删除的粗枝大叶

//crt\u fscanf\u s.c
//这个程序写的是格式化的
//将数据保存到文件中。然后,它使用fscanf
//从文件中读回各种数据。
#包括
#包括
文件*流;
内部主(空)
{
长l;
浮点数;
chars[81];
字符c;
errno_t err=fopen_s(&stream,“fscanf.out”,“w+”);
如果(错误)
printf_s(“文件fscanf.out未打开\n”);
其他的
{
fprintf_s(流,“%s%ld%f%c”,“a字符串”,
65000,3.14159,'x');
//设置指向文件开头的指针:
fseek(流、0L、寻道集);
//从文件中读回数据:
fscanf_s(流,“%s”,s,_countof(s));
fscanf_s(流、%ld、&l);
fscanf_s(流、%f、&fp);
fscanf_s(流、%c、&c,1);
//输出数据读取:
printf(“%s\n”,s);
printf(“%ld\n”,l);
printf(“%f\n”,fp);
printf(“%c\n”,c);
fclose(流);
}
}

不要使用FSCAN。如果它不安全,不应该再使用,请使用FSCAN。C是一种古老的语言,因此它有许多不应该使用的、不能删除的粗枝大叶

//crt\u fscanf\u s.c
//这个程序写的是格式化的
//将数据保存到文件中。然后,它使用fscanf
//从文件中读回各种数据。
#包括
#包括
文件*流;
内部主(空)
{
长l;
浮点数;
chars[81];
字符c;
errno_t err=fopen_s(&stream,“fscanf.out”,“w+”);
如果(错误)
printf_s(“文件fscanf.out未打开\n”);
其他的
{
fprintf_s(流,“%s%ld%f%c”,“a字符串”,
65000,3.14159,'x');
//设置指向文件开头的指针:
fseek(流、0L、寻道集);
//从文件中读回数据:
fscanf_s(流,“%s”,s,_countof(s));
fscanf_s(流、%ld、&l);
fscanf_s(流、%f、&fp);
fscanf_s(流、%c、&c,1);
//输出数据读取:
printf(“%s\n”,s);
printf(“%ld\n”,l);
printf(“%f\n”,fp);
printf(“%c\n”,c);
fclose(流);
}
}
// crt_fscanf_s.c
// This program writes formatted
// data to a file. It then uses fscanf to
// read the various data back from the file.

#include <stdio.h>
#include <stdlib.h>

FILE *stream;

int main( void )
{
   long l;
   float fp;
   char s[81];
   char c;

   errno_t err = fopen_s( &stream, "fscanf.out", "w+" );
   if( err )
      printf_s( "The file fscanf.out was not opened\n" );
   else
   {
      fprintf_s( stream, "%s %ld %f%c", "a-string",
               65000, 3.14159, 'x' );
      // Set pointer to beginning of file:
      fseek( stream, 0L, SEEK_SET );

      // Read data back from file:
      fscanf_s( stream, "%s", s, _countof(s) );
      fscanf_s( stream, "%ld", &l );

      fscanf_s( stream, "%f", &fp );
      fscanf_s( stream, "%c", &c, 1 );

      // Output data read:
      printf( "%s\n", s );
      printf( "%ld\n", l );
      printf( "%f\n", fp );
      printf( "%c\n", c );

      fclose( stream );
   }
}