VS2013 fopen_s 用法
来源:互联网 发布:java b2b2c 开源下载 编辑:程序博客网 时间:2024/06/08 12:05
参考:
http://bbs.csdn.net/topics/190162053
//一个正确使用的例子// crt_fopen_s.c// This program opens two files. It uses// fclose to close the first file and// _fcloseall to close all remaining files. #include <stdio.h>FILE *stream, *stream2;int main( void ){ int numclosed; errno_t err; // Open for read (will fail if file "crt_fopen_s.c" does not exist) if( (err = fopen_s( &stream, "crt_fopen_s.c", "r" )) !=0 ) printf( "The file 'crt_fopen_s.c' was not opened\n" ); else printf( "The file 'crt_fopen_s.c' was opened\n" ); // Open for write if( (err = fopen_s( &stream2, "data2", "w+" )) != 0 ) printf( "The file 'data2' was not opened\n" ); else printf( "The file 'data2' was opened\n" ); // Close stream if it is not NULL if( stream) { if ( fclose( stream ) ) { printf( "The file 'crt_fopen_s.c' was not closed\n" ); } } // All other files are closed: numclosed = _fcloseall( ); printf( "Number of files closed by _fcloseall: %u\n", numclosed );}
scanf_s("%s",filename);//应有第三个参数指定filename中可以存入字符的个数,第三个参数默认为0,不重新指定则,filename中什么也得不到
应该例如:
scanf_s("%s",filename,10);
0 0
- VS2013 fopen_s 用法
- fopen_s
- fopen_s
- fopen_s
- vs2013遇到fopen不安全替换fopen_s的问题
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s用法的比较
- fopen和fopen_s fscanf和fscanf_s用法的比较
- VS2013解决rror C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead
- fopen_s()函数
- “fopen”被声明为否决的警告问题以及fopen_s的用法
- C/C++打开文件函数fopen和fopen_s用法的比较
- fopen函数、fopen_s函数、fclose函数、fscanf函数、memset函数、strcpy函数、strcpy_s函数、strcat函数和fprintf函数用法?
- JAVA_SE基础——38.单例设计模式
- 在VS2010下创建一个OpenGL的程序框架
- iOS字典数组,把每个字典对象转成一个模型对象
- 不用额外变量交换两个整数的值
- USACO 2.3.4 Money Systems
- VS2013 fopen_s 用法
- 【小游戏】俄罗斯方块(C++版)
- HTML冷门标签
- POD类型的几点总结
- runtime之实现方法交换(简单版本)
- HTTP摘要认证方式分析与验证
- maven POM.xml 标签详解
- poj 2189/3061 贪心(找连续的羊圈/连续子序列之和大于limit的最短序列)
- 第一季果实