argv简单应用
上一篇 /
下一篇 2012-08-06 12:34:22
/ 个人分类:C/C++
命令行使用
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i=0;
while(argv[i])
cout << argv[i++] << " ";
cout<<endl;
cout << "argc=" << argc << endl;
cout << "i=" << i << endl;
cout << "argv[]:" << *(argv[0])<< endl;
getchar();
char * pFilePath = argv[1];//作用等价,只是要在命令窗口输入,此处argv[0]默认是test.exe
char sFilePath[255] = {0};
memcpy(sFilePath,"E:\\test\\test.txt",strlen("E:\\test\\test.txt"));
//strncpy(sFilePath,"E:\\test\\test.txt",strlen("E:\\test\\test.txt"));
return 0;
}
收藏
举报
TAG: