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:

 

评分:0

我来说两句

日历

« 2024-04-28  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 3477
  • 日志数: 13
  • 书签数: 3
  • 建立时间: 2012-08-01
  • 更新时间: 2012-12-30

RSS订阅

Open Toolbar