一运行,黑屏一闪而过,说本机已退出,返回值是0(0x0)?怎么解

求学为上 2015-09-14 11:35:06
#include<stdio.h>
#include<iostream>
int main()
{
printf("helloworld\n");
system("pause");
return 0;
}
一运行黑屏一闪而过:
“Helloworld.exe”: 已加载“D:\Program Files\opencvvs2010\Helloworld.exe”,已加载符号。
“Helloworld.exe”: 已加载“C:\Windows\System32\ntdll.dll”,已加载符号(去除源信息)。
“Helloworld.exe”: 已加载“C:\Windows\System32\kernel32.dll”,已加载符号(去除源信息)。
“Helloworld.exe”: 已加载“C:\Windows\System32\KernelBase.dll”,已加载符号(去除源信息)。
“Helloworld.exe”: 已加载“C:\Windows\System32\msvcr100d.dll”,已加载符号。
BasepCheckCacheExcludeList: Cache not allowed for \??\C:\Windows\system32\cmd.exe
BasepShimCacheLookup: Entry for \??\C:\Windows\system32\cmd.exe was disallowed yet found in cache, cleaning up
Application "\??\C:\Windows\system32\cmd.exe" not found in cache
“Helloworld.exe”: 已加载“C:\Windows\System32\apphelp.dll”,已加载符号(去除源信息)。
“Helloworld.exe”: 已加载“ImageAtBase0xd40000”,“包括”/“排除”设置禁用了加载功能。
“Helloworld.exe”: 已卸载“ImageAtBase0xd40000”
程序“[7124] Helloworld.exe: 本机”已退出,返回值为 0 (0x0)。

直接按Ctrl+F5也是这样,想问一下是什么原因啊?
...全文
22106 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
中二短尾猫 2018-08-25
  • 打赏
  • 举报
回复
不用system("pause");
你用Dev-c++试试
程耀辉 2018-08-13
  • 打赏
  • 举报
回复 14
CTRL+F5是执行不调试、你按CTRL+F5就会解决。
赵4老师 2016-05-09
  • 打赏
  • 举报
回复
现在的码农竟然99%都不会在cmd窗口中输入cd命令设置当前目录为程序所在目录,输入程序名运行程序了!
月凉西厢 2016-05-09
  • 打赏
  • 举报
回复 6
本来就是这样的,你点的运行,程序就运行了,但是这个程序的执行时间比较短,因此一闪就没了。 点 “运行不调试”就可以了,以前我新手的时候也烦这个,别人告诉我getchar()。后来才发现自己的运行方式有问题
sunchengxx 2016-05-08
  • 打赏
  • 举报
回复
我也是啊。。。
半途流浪 2016-04-26
  • 打赏
  • 举报
回复
我也是。用了几乎找到的所有方式都不可以。。。
赵4老师 2016-04-15
  • 打赏
  • 举报
回复
建议你先编译链接调试OpenCV自带的相关例子代码。
qq_34661578 2016-04-15
  • 打赏
  • 举报
回复
#include <stdio.h> // For printf() #include <cv.h> // Main OpenCV library. #include <highgui.h> // OpenCV functions for files and graphical windows. using namespace std; using namespace cv; // Initialize a sub funcion using after main CvRect detectFaceInImage( IplImage *inputImg, CvHaarClassifierCascade* cascade); int main(int argc, char* argv[]) { CvPoint pt1, pt2; // For draw rectangle // Check the input is correct when call executable file if (argc != 2) { printf("Usage: faceDetector.exe <imagename>\n"); exit(-1); } char * imgName = argv[1]; // Copy the second input as the image name // Load image IplImage* inputImg = cvLoadImage(imgName, CV_LOAD_IMAGE_UNCHANGED); if (!inputImg) { printf("Error: Could not open the image file! \n"); exit(-1); } // Haar Cascade file, used for Face Detection. // Note: you could change this directory as your installed OpenCV2.1 location char *faceCascadeFilename = "C:/OpenCV2.1/data/haarcascades/haarcascade_frontalface_alt.xml"; // Load the HaarCascade classifier for face detection. CvHaarClassifierCascade* faceCascade; faceCascade = (CvHaarClassifierCascade*)cvLoad(faceCascadeFilename, 0, 0, 0); if( !faceCascade ) { printf("Couldnt load Face detector '%s'\n", faceCascadeFilename); exit(-1); } // Perform face detection on the input image, using the given Haar classifier CvRect faceRect = detectFaceInImage(inputImg, faceCascade); // Make sure a valid face was detected then draw the rect location. if (faceRect.width > 0) { printf("Detected a face at (%d,%d)!\n", faceRect.x, faceRect.y); // Get the pointer of the face rectangle pt1.x = faceRect.x; pt2.x = faceRect.x + faceRect.width; pt1.y = faceRect.y; pt2.y = faceRect.y + faceRect.height; // Draw the rectangle in the input image cvRectangle( inputImg, pt1, pt2, CV_RGB(255,0,0), 2, 8, 0 ); // Show the detected face image on the screen. cvNamedWindow("Detected face", CV_WINDOW_AUTOSIZE); // Show the image in the window named "Detected face", you could change as you like cvShowImage( "Detected face", inputImg ); // Wait for the user to press something on the graphical window. // Note: cvWaitKey() is needed for time to draw on the screen. cvWaitKey(0); // Free the resources. cvDestroyWindow("Detected face"); cvReleaseImage( &inputImg ); } // Free the Face Detector resources when the program is finished cvReleaseHaarClassifierCascade( &faceCascade ); return 0; } // Perform face detection on the input image, using the given Haar Cascade. // Returns a rectangle for the detected region in the given image. CvRect detectFaceInImage(IplImage *inputImg, CvHaarClassifierCascade* cascade) { // Smallest face size. CvSize minFeatureSize = cvSize(20, 20); // Only search for 1 face. int flags = CV_HAAR_FIND_BIGGEST_OBJECT | CV_HAAR_DO_ROUGH_SEARCH; // How detailed should the search be. float search_scale_factor = 1.1f; IplImage *detectImg; IplImage *greyImg = 0; CvMemStorage* storage; CvRect rc; //double t; CvSeq* rects; CvSize size; int nFaces; //int i, ms; storage = cvCreateMemStorage(0); cvClearMemStorage( storage ); // If the image is color, use a greyscale copy of the image. detectImg = (IplImage*)inputImg; if (inputImg->nChannels > 1) { size = cvSize(inputImg->width, inputImg->height); greyImg = cvCreateImage(size, IPL_DEPTH_8U, 1 ); cvCvtColor( inputImg, greyImg, CV_BGR2GRAY ); detectImg = greyImg; // Use the greyscale image. } // Detect all the faces in the greyscale image. //t = (double)cvGetTickCount(); rects = cvHaarDetectObjects( detectImg, cascade, storage, search_scale_factor, 3, flags, minFeatureSize); //t = (double)cvGetTickCount() - t; //ms = cvRound( t / ((double)cvGetTickFrequency() * 1000.0) ); nFaces = rects->total; //printf("Face Detection took %d ms and found %d objects\n", ms, nFaces); // Get the first detected face (the biggest). if (nFaces > 0) rc = *(CvRect*)cvGetSeqElem( rects, 0 ); else rc = cvRect(-1,-1,-1,-1); // Couldn't find the face. if (greyImg) { cvReleaseImage( &greyImg ); } cvReleaseMemStorage( &storage ); return rc; // Return the biggest face found, or (-1,-1,-1,-1). } 这个程序也是和你的程序一样的毛病,请大神帮我也改改吧
赵4老师 2015-09-29
  • 打赏
  • 举报
回复
听本版等级高的人的回复,准没错!
qq_15061391 2015-09-29
  • 打赏
  • 举报
回复
system 在stdlib.h头文件中
ramay7 2015-09-16
  • 打赏
  • 举报
回复
加头文件 #include <stdlib.h>
赵4老师 2015-09-14
  • 打赏
  • 举报
回复
开始、运行、cmd、确定。输入以下命令: cd /d 你的exe文件所在盘符和目录 你的exe文件名
求学为上 2015-09-14
  • 打赏
  • 举报
回复
用的是vs2010
此后三年 2015-09-14
  • 打赏
  • 举报
回复
你确定是控制台程序? 在system("pause");前面加上getchar(); 试试
ipqtjmqj 2015-09-14
  • 打赏
  • 举报
回复
exe 程序,exe是 execute的缩写,意为执行,也有处决的意思,程序执行完,当然就退出了。而常见的图形界面程序,它本身就是一个无限循环,只有用户点了关闭按扭后,才退出。
lm_whales 2015-09-14
  • 打赏
  • 举报
回复
因为控制台程序, 不在现有控制台(cmd)下运行,而是窗口下运行,的缺省设置,是退出控制台。 这是windows 的把戏 你可以先打开一个cmd 控制台窗口 然后命令行 运行 它 调试的时候 指定命令行参数,用 cmd 加载它 即可 也可以,制定一个快捷方式 用 cmd 加载它,双击快捷方式运行。
ruying1389279 2015-09-14
  • 打赏
  • 举报
回复 1
引用 4 楼 duhao358231384 的回复:
上面两种方法都可以,那么为什么不加getchar生成的.exe运行就不行了?
你在代码最前面加上一句 #include <windows.h>试试,getchar()的作用就是等待键盘输入,程序运行到getchar()就等待输入了,所以就不会一闪而过。
求学为上 2015-09-14
  • 打赏
  • 举报
回复
上面两种方法都可以,那么为什么不加getchar生成的.exe运行就不行了?

33,322

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧