首先接受价值的C ++ / C应用程序。 [英] C++/C application that accept value in the first place.

查看:48
本文介绍了首先接受价值的C ++ / C应用程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我想知道我将如何编写一个首先接受价值的简单C ++ / C应用程序。



例如..我的应用程序名称将是myCommand,我的值是50。我将在命令行中编写类似于unix basemyCommand 50的内容。

然后我的代码将从命令行接收值50然后它将打印回来的值



原始代码:



Hi..
I want to know how i''m going to wrote a simple C++/C application that accept value in the first place.

For example..my Application name will be "myCommand" and my value is "50". I will wrote in the command line something like this in unix base "myCommand 50".
then my code will receive the value "50" from the command line then it will print back the value

the original code :

#include <stdio.h>

main() {
int count;
puts("Please enter a number: ");
scanf("%d", &count);
printf("The number is %d \n", count);
} 





请帮忙??



Please help ??

推荐答案

嗯......这是一个技巧问题吗?



Ummm ... Is this a trick question?

#include <iostream>

using namespace std;

int main( int argc, char* argv[] )
{
  cout << "Program name: " << argv[0]
       << "\nArgument: " << argv[1]; << "\n";
  return 0;
}





听起来你可能想用argv [1]调用ShellExecute()或相关的API。 br />


你编辑了你的问题,现在它问了一些不同的东西;但我认为我的答案仍然回答了更新的问题。只需忽略ShellExecute()部分。[/ Edit]



It sounds like you probably want to call ShellExecute() or a related API with argv[1].

You editted your question so that it now asks something different; however I think my answer still answers the updated question. Just ignore the "ShellExecute() part.[/Edit]


这篇关于首先接受价值的C ++ / C应用程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆