参数主要用C [英] Arguments to main in C

查看:295
本文介绍了参数主要用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道该怎么办!我对C的基础知识非常了解。结构,文件IO,字符串,等等一切,但CLA。出于某种原因,我不能把握的概念。任何建议,帮助或建议。 PS我是一个Linux用户

I don't know what to do! I have a great understanding of C basics. Structures, file IO, strings, etc. Everything but CLA. For some reason I cant grasp the concept. Any suggestions, help, or advice. PS I am a linux user

推荐答案

的签名是:

int main(int argc, char **argv);

ARGC 是指通过在命令行参数,其中的包含程序的实际名称,由用户调用的数量。 的argv 包含实际的参数,索引1开始索引0是程序名。

argc refers to the number of command line arguments passed in, which includes the actual name of the program, as invoked by the user. argv contains the actual arguments, starting with index 1. Index 0 is the program name.

所以,如果你运行你的程序是这样的:

So, if you ran your program like this:

./program hello world

然后:


  • 的argc是3。

  • 的argv [0]将是./program。

  • 的argv [1]将是你好。

  • 的argv [2]将是世界。

这篇关于参数主要用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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