将值传递到函数-C语言的命令行

发布于 2025-01-28 03:51:19 字数 1334 浏览 2 评论 0 原文

我正在尝试找出如何将函数的输出值传递到C文件中的命令行。该变量的名称是“ cext”,“ cabs”。程序的默认行为是创建一个文件夹,其中包含打印输出的C文件。我必须编辑的代码如下:

”“在此处输入图像描述”

在第922-925行中,

CCfile=FOpenErr(fname,"w",ONE_POS);
PrintBoth(CCfile,"Cext\t= "GFORM"\nQext\t= "GFORM"\n",Cext,Cext*inv_G);
PrintBoth(CCfile,"Cabs\t= "GFORM"\nQabs\t= "GFORM"\n",Cabs,Cabs*inv_G);
FCloseErr(CCfile,F_CS,ONE_POS);

我应该做什么变化?因此,我可以在命令行上获得值,而不是将其存储在数组中。对阅读或示例代码的任何链接/文本都将不胜感激吗?我以前曾查看过这些链接,但我仍然尚未将其弄清楚

  1. Pass从命令行进入C程序的参数
  2. cragments> in Main to c
  3. https://www.geeksforgeekss.org/command-line-arguments-inguments-inguments-in -c-cpp/

I am trying to find out how to pass output value of a function into command line in a C file. The name of the variable is "Cext", "Cabs". The default behavior of the program is to create a folder which contains C files in which the output is printed. The code where I have to edit is as follows:

enter image description here

In the lines 922-925,

CCfile=FOpenErr(fname,"w",ONE_POS);
PrintBoth(CCfile,"Cext\t= "GFORM"\nQext\t= "GFORM"\n",Cext,Cext*inv_G);
PrintBoth(CCfile,"Cabs\t= "GFORM"\nQabs\t= "GFORM"\n",Cabs,Cabs*inv_G);
FCloseErr(CCfile,F_CS,ONE_POS);

What changes I should make? So i can get the value on the command line and than store it in an array. Any links/ text to read or sample code would be highly appreciated? I have previously looked at these links but i still haven' figured it out

  1. Pass arguments into C program from command line
  2. Arguments to main in C
  3. https://www.geeksforgeeks.org/command-line-arguments-in-c-cpp/
  4. https://techvidvan.com/tutorials/command-line-arguments-in-c/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清醇 2025-02-04 03:51:19
strncpy(fname_cs,"dev/null",400)

必须在c文件中多次编写这条代码行,因此没有打印任何印刷,而是在shell中,我将数据传输到变量之前,然后将其删除。

strncpy(fname_cs,"dev/null",400)

had to write this line of code multiple times in the c file, so nothing is printed and than in the shell, i transferred the data to a variable before it is deleted.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文