当前位置:网站首页>[problem solving] vs2019 solves the problem that the EXE file generated by compilation cannot be opened
[problem solving] vs2019 solves the problem that the EXE file generated by compilation cannot be opened
2022-04-23 08:04:00 【Pluse Lin】
Problem description
I am a college student majoring in computer , In use recently VS When doing big homework , Suddenly found the use of Release Compiled in mode exe Double click the file to flash back . I checked various methods on the Internet , The corresponding settings have also been modified , But it still doesn't work .
resolvent
Then I suddenly remembered my big homework and used ifstream Read in the file , To be read txt And cpp The files are in the same directory , Therefore, the relative address is used ! That's why , So in VS No error was reported during debugging , And I didn't give an error prompt for file opening failure in the code , It's a waste of time . I threw up .
The modification method is : The files to be read and exe Just put the files in the same folder .
summary
If you write C++ Generated by program compilation exe The file can't be opened , There can be the following solutions :
1. stay main function return 0 with system(“pause”)( In theory, we need <Windows.h> The header file , but VS2019 It seems that there is no need for )
2. Modify the corresponding settings ( There are a lot of , Do not go into , In fact, I didn't remember too many changes myself )
3. Consider whether it is possible that the flash back caused by program running error . For example, the above example , If the file fails to read in, it will exit the program directly .
Besides , If you use ifstream Read in the file , It is strongly recommended to judge whether the file was successfully opened , My usual way of writing is :
const char* path="in.txt";
ifstream In(path);
if(In.is_open()){
...// Your operation
}
else{
cerr<<" File opening failure !"<<endl;
exit(-1);
}
In.close();
For dynamic memory applications , You can also refer to the above writing . Or use advanced try-catch How to write it .( But I'm too good to )
I hope I can think more and pay more attention to details in the future , I also hope you will not step on similar pits .
版权声明
本文为[Pluse Lin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230629306872.html
边栏推荐
- C problem of marking the position of polygons surrounded by multiple rectangles
- About USB flash drive data prompt raw, need to format, data recovery notes
- 云计算技能大赛 -- openstack私有云环境 第二部分
- KVM安装部署
- Using lambda expression to solve the problem of C file name sorting (whether it is 100 or 11)
- Shapley Explanation Networks
- Houdini流体>>粒子流体导出到unity笔记
- C # control the camera, rotate and drag the observation script (similar to scenes observation mode)
- Sto with billing cross company inventory dump return
- Export all SVG files in the specified path into pictures in PNG format (thumbnail or original size)
猜你喜欢

Houdini fluid > > particle fluid export to unity note

Simplify exporting to SVG data files and all images in SVG folder

MySQL -- the secret of lock -- how to lock data

VBA appelle SAP RFC pour réaliser la lecture et l'écriture des données

Houdini>流体,刚体导出学习过程笔记

【编程实践/嵌入式比赛】嵌入式比赛学习记录(一):TCP服务器和web界面的建立

Concours de compétences en informatique en nuage - - première partie de l'environnement cloud privé openstack

VBA调用SAP RFC实现数据读取&写入

Intranet penetration series: ICMP of Intranet tunnel_ Tran

内网渗透系列:内网隧道之icmp_tran
随机推荐
CTF攻防世界刷题51-
How to present your digital portfolio: suggestions from creative recruiters
Robust and Efficient Quadrotor Trajectory Generation for Fast Autonomous Flight
linux下mysql数据库备份与恢复(全量+增量)
Essays (updated from time to time)
Redis事务实现乐观锁原理
内网渗透系列:内网隧道之icmptunnel(DhavalKapil师傅的)
Internal network security attack and defense: a practical guide to penetration testing (8): Authority maintenance analysis and defense
1+x云计算中级--脚本搭建读写分离
Redis--为什么字符串emstr的字符串长度是44字节上限?
Research on software security based on NLP (2)
When using flash, the code ends automatically without an error, the connection cannot be maintained, and the URL cannot be accessed.
VBA调用SAP RFC实现数据读取&写入
What's new in. Net 5 NET 5
Research on system and software security (3)
Automatically fit single line text into the target rectangle
SAP sto with billing process and configuration
【问题解决】VS2019解决编译生成的exe文件打不开的情况
Dvwa 靶场练习记录
数据库之MySQL——基本常用查询命令