C Programming - Command Line Arguments - Discussion

3. 

Does there exist any way to make the command-line arguments available to other functions without passing them as arguments to the function?

[A]. Yes
[B]. No

Answer: Option A

Explanation:

Using the predefined variables _argc, _argv. This is a compiler dependent feature. It works in TC/TC++ but not in gcc and visual studio.

Madhu said: (Mar 4, 2011)  
Can any one explain how _argc and _argv are used with an example?

Preetha said: (Jun 2, 2011)  
Can any one explain how _argc and _argv are used with an example?

Proiya said: (Aug 6, 2011)  
Explain _argc and _argv ?

Rupinderjit said: (Dec 8, 2011)  
These are global variable and available to all files and associated functions throughout the program.

Spiro said: (Jul 5, 2012)  
You can assign argc and argv to your own global variables and not rely on existence of any default globals.

Suganya said: (Sep 6, 2012)  
Explain _argc and _argv?

George said: (Jan 8, 2013)  
For those trying to use _argc, _argv - note that it works only in TurboC!

X0R said: (Sep 4, 2016)  
When a program starts, _start calls __libc_start_main which in turn calls main.Then in _start, rdx register points to argv and rsi register points to argc, and they are pushed into the stack. So just carefully craft a pointer and you can access them from main.

Shivan said: (Jun 7, 2017)  
Anyone please explain it.

Mounica said: (Aug 15, 2017)  
Explain it with the example.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.