/*
1 解析参数,argc表示参数数量,argv表示参数内容
//cmd命令行:c:/Users/lenonvo/>./main.exe -s 3.24567 -p 7.4566
2 string 转 double
3 cout 示例/printf 示例
4 double 转 string
4.5 int 转 string
5 暂停控制台,不退出。
*/
#include <iostream>
#include <string>
#include <stdio.h>
#include <windows.h>
using namespace std;
void print_help()
{
std::cout << "eye_tracking" << std::endl;
}
string dtostr(double value) {
char buffer[20];
_gcvt_s(buffer, 20, value, 15);
string str = buffer;
return str;
}
int main(int argc, char ** argv) {
double slant;
double pitch;
int s, p;
//1 解析参数,argc表示参数数量,argv表示参数内容
//cmd命令行:c:/Users/lenonvo/>./main.exe -s 3.24567 -p 7.4566
for (int i = 1; i < argc; i++)
{
printf("Argument %d is %s\n", i, argv[i]);
if (strcmp(argv[i], "-s") == 0)
{
string slanttemp = argv[i + 1];
//2 string 转 double
slant = atof(slanttemp.c_str());
}
else if (strcmp(argv[i], "-p") == 0)
{
string pitchtemp = argv[i + 1];
//3 string 转 double
pitch = strtod(pitchtemp.c_str(), NULL);
}
else if (strcmp(argv[i], "--help") == 0)
{
print_help();
return -1;
}
// int 转string
LPCSTR temp = to_string(dh).c_str();
}
// 5 cout 示例
std::cout <<"slant:"<< slant << std::endl;
std::cout <<"pitch:"<< pitch << std::endl;
// 4 double 转 string
std::cout << "slant:"+to_string(slant) << std::endl;
std::cout << "pitch:" + to_string(pitch) << std::endl;
// 6 printf 示例
printf("Argument is %f\n", slant);
printf("Argument is %f\n", pitch);
s = slant;
p = pitch;
printf("Argument is %d\n", s);
printf("Argument is %d\n", p);
// 7 暂停控制台,不退出。
system("pause");
//getchar();
//Sleep(5000000);
//while (1)
//{
// int x;
// cin >> x;
//}
//char a;
//while(cin>>a);
return 0;
}