在启动时为应用程序提供一些数据
Giving the application some data on launch
我正在尝试创建一个应用程序,可以从另一个程序启动时接收一些数据。例如:
Start_App.exe calls Main_App.exe and gives it the current date, all at the same time
(while launching it)
Main_App.exe outputs the date on its console
如果没有Start_App传递的数据,其他程序就不能正常工作或将做其他事情。我一直在找,但似乎我错过了技术名称…
您可能需要使用命令行参数。
它们通过直接在程序名之后用空格分隔的方式写出来传递。
像这样:
#include <iostream>
int main(int argc, char *argv[])
{
using namespace std;
cout << "There are " << argc << " arguments:" << endl;
// Loop through each argument and print its number and value
for (int nArg=0; nArg < argc; nArg++)
cout << nArg << " " << argv[nArg] << endl;
return 0;
}
argc
是程序接收到的参数个数。*argv[]
是字符串数组,每个参数对应一个字符串。
如果你像这样调用程序:
Program.exe arg1 arg2 arg3
它给你:
There are 3 arguments:
0 arg1
1 arg2
2 arg3
相关文章:
- PC中的程序和PHONE中的本机描述应用程序之间的数据连接
- 如何在不破坏现有应用程序的情况下更改 API 中 stl 容器的数据类型?
- 在 1 个服务器 n 客户端套接字 C++ MFC 应用程序中更新数据的客户端
- 错误: 无效使用非静态数据成员"应用程序::应用程序构造函数"
- 更改应用程序数据的路径
- 使用 pipe() 和 fdopen() 将数据从 Python 脚本传递到 Windows 中的C++应用程序
- 将数据从一个应用程序单向发送到另一个应用程序的最佳做法
- 从 Windows 中的其他应用程序 GUI 中提取数据
- 无法使用管道将数据发送到我通过exec(C++)启动的第二个应用程序
- 在网格视图中显示数据 - 基于 MFC c++ 对话框的应用程序
- 安卓中的Qt和应用程序数据存储
- 从Qt应用程序读取元数据
- 是否有一种简单的方法可以从普通的 win32 C++代码向应用程序见解提供数据?
- 如何使用Qt读取我的应用程序屏幕像素数据
- 在 API 和应用程序线程之间共享数据
- QT MAC应用程序存储数据路径
- 如何在 Windows 中保存特定于应用程序的数据
- 将大量数据从C 应用程序传递到SQLServer存储过程的最快方法是什么?
- C++应用程序中的静态数据内存限制
- wxWidgets 应用程序中的 SOCI 数据类型