c.cc文件:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char const *argv[])
{
int a,b,c;
a = atoi(argv[1]); //字符串转整数
b = atoi(argv[2]);
c = a * b;
char *outcome;
sprintf(outcome,"%d",c); //整数转字符串
std::cout<<argv[1]<<"*"<<argv[2]<<"="<<outcome<<std::endl;
while(getchar()!='q');
return 0;
}
编译:
g++ c.cc -o c
运行:
./c Two\ Young
结果:
Hello World! Two Young!