int main( int argc ,char** argv) windows下如何传递参数

来源:互联网 发布:2017七天网络成绩查询 编辑:程序博客网 时间:2024/05/01 12:23

     今天开始学习OpenCV,由于本人实在是小白,c语言功底不扎实,更不用说c++了,所以学什么都得从最基础看。打好基础吧。

     开始的第一个程序:

     

<span style="font-size:18px;">#include "highgui.h"int main( int argc , char** argv){IplImage* img = cvLoadImage( argv[1] );cvNamedWindow( "Example1",CV_WINDOW_AUTOSIZE );cvShowImage( "Example1", img );cvWaitKey(0);cvReleaseImage( &img);cvDestroyWindow( "Example1" );}</span>

环境是vs2012,点击编译,只是出来一个黑框。因为无图片传入。

这个程序是通过main函数的argv传递图片进入程序的,,, ,,,好吧,可是出来的cmd窗口不能输入。

<span style="font-size:18px;">int main( int argc , char** argv)这个函数在linux系统下怎么操作我在之前的<a target=_blank href="http://blog.csdn.net/qq_16583687/article/details/51198003">博客里面</a>已经说过了,而windows的cmd与linux终端相似,所以搜索看了一下,原理是一样的。</span>
<span style="font-size:18px;"></span>
<span style="font-size:18px;">把图片放入到编译生成的可执行文件.exe文件里面,再打开cmd命令,输入d:进入d盘;输入dir查看目录下面的内容;输入cd 文件夹进入文件,和linux shell下面的命令很接近,找到.exe文件的目录,输入可执行文件名.exe 图片名.png就可以显示图片。</span>
<span style="font-size:18px;"></span>
<span style="font-size:18px;">以下附上一些cmd命令,以后可能会用到:来自:http://blog.csdn.net/davidweish/article/details/5943668</span>
<p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:dir,列文件、目录</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/-c</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:dir列文件、目录时显示的文件大小,其数值以千为单位进行分隔,使用此参数即“dir/-c”将取消显示中的分隔符,以满足部分人的视觉习惯。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/q</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:windows是多用户操作系统,使用此参数即“dir /q”列文件、目录时,将显示出文件、目录的用户属性。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/t:c、/t:a、/t:w</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“dir/t:c”、“dir/t:a”、“dir/t:w”分别显示文件、目录的创建时间、上次访问时间和上次修改时间。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/x</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“dir/x”列文件、目录时,会对长文件名同时显示“8.3”格式的文件名。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:cd,改变目录</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/d</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:此参数的作用是快速改变当前目录,比如当前目录是c:windows,使用命令“cd/d e:tools”可快速切换到e:tools目录下。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">注:只有在win xp的“运行”文本框中输入“cmd”得到的dos窗口中才能使用此参数。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:md,建立目录</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">功能说明:此命令并未增加参数,但是增强了功能,它可一次建立多级子目录,例如使用命令“md aabbccdd”将一次性创建aa、bb、cc、dd四级子目录。而在老版本的dos中,若不存在aa子目录,便无法直接建立aa下的bb等深层子目录。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:rd,删除目录</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/s</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“rd/s”用于删除目录树,即删除目录及目录下的所有子目录和文件,相当于以前版本中的deltree命令。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/q</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用上面的/s参数删除目录树时,系统会要求用户确认是否真的要删除。若同时使用/q参数即“rd/s /q”,在进行删除操作时将取消确认,相当于deltree命令的/y参数。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:del,删除文件或目录</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/f</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“del/f”可删除只读文件。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/s、/q</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“del/s”作用与“rd/s”完全相同,即删除目录及目录下的所有子目录和文件。同时使用参数/q,可取消删除操作时的系统确认。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/a</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:删除指定属性或指定属性以外的文件,/ar、/ah、/as、/aa分别表示删除只读、隐藏、系统、存档文件,/a-r、/a-h、/a-s、 /a-a表示删除除只读、隐藏、系统、存档以外的文件。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">例如“del/ar *.*”表示删除当前目录下所有只读文件,</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">“del/a-s *.*”表示删除当前目录下除系统文件以外的所有文件。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:attrib,更改文件或目录的属性</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/d</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:在win xp中我们不能把文件或文件夹设置为系统属性,只能设为只读、隐藏或存档属性。而带参数/d使用attrib命令可以对文件的所有属性进行设定,设定时必须与参数/s同时使用。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">例如“attrib /s /d +s d:study”,作用是将d:study文件夹设置为系统文件夹。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:format,格式化磁盘</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/fs:filessystem</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:按指定文件系统类型(fat、fat32、ntfs)格式化磁盘,</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">例如“format /fs:ntfs”。</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">命令:date、time,显示系统日期和时间</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">增加参数:/t</span></p><p style="color: rgb(51, 51, 51); font-family: Arial; line-height: 26px;"><span style="font-size:18px;">参数说明:使用此参数即“date/t”、“time/t”将只显示当前日期和时间,而不必输入新日期和时间。</span></p><span style="font-size:18px;"></span>


0 0
原创粉丝点击