DEV Community

Abdullah-fy
Abdullah-fy

Posted on

argc & argv[] in c

*argc *:- represent the number of things you entering into the command line when running this program in a terminal.

argv[] :- is an array that hold the string values of the things we were entered on the command line when running this program in a terminal.

example on argc
this is the code

Image description

now after compile and run

Image description

notice ./argc.o
give you value 1
when you enter other value next to it , it gives you the number of it , and also what is between these practice " " is only is only one value

now argv

Image description

Image description

argc gives the number of intered value
argv gives the value the entered as string

if i will enter some numbers and want to sum them, so i need to turn this string to in , i will use atoi for it

Image description

the answer

Image description

Top comments (0)