Question:
what is a command line in c?
Yuuki
2013-06-10 12:52:59 UTC
my textbook said that command line "causes the compiled and linked program to execute", but i didn't understand.
in the first place, is a command line a function, or a line in the code?
Seven answers:
Almighty Wizard
2013-06-10 12:54:24 UTC
The command line is where you type your commands... it's the black window prompt. Seriously, if you don't know what the command line is, you will have serious problems with coding.
husoski
2013-06-10 14:14:40 UTC
The command line is a line of text that is input to a command processor. The command processor parses the command line and typically runs on or more programs to accomplish what the command "commanded". In a Unix/Linux type system, the command processor is called a "shell", and there are several different ones in common use. Windows has the Command Prompt (aka "CMD" or "the DOS prompt"), plus other choices (like "PowerShell").



Another place that command lines are used with C or C++ programming is in the "make" file. This is a file with lines of text describing all of the files used to build a project, what files are creating during the build process, along with a list of the commands needed to create them.



So, a command line isn't a place or a function. It is an input line that can come from different places.
Chip
2013-06-10 12:55:22 UTC
The textbook is worded awkwardly, but I think they are talking about your normal windows/linux command line. A fully-compiled program can be run from the command line just like any other program.
jplatt39
2013-06-10 13:05:34 UTC
The command line is an interpreter. Seriously. It is a program which accepts input from the keyboard or a file and executes other programs or functions depending on what is typed in. It can be cmd.exe in Windows or it can be the bash shell in UNIX, Mac OS or Linux. It's the default way for getting input and giving output in C and C++.
Shady
2013-06-10 13:11:06 UTC
Most people are taught



int main()

{

//stuff

return 0;

}



The proper way is



int main(int argc, char** argv)

{

printf("The number of arguments are %d\n", argc);

printf("The first argument is %s\n", argv[0]);

return 0;

}



the arguments are stored in a char array.. the number of arguments are stored as an int.



These arguments are given from the command line. Just google how to enter in command line arguments with whichever IDE/compiler you are using.
Tyler
2013-06-10 13:03:18 UTC
arguments are passed at the time you run the program to the main function.
2014-12-04 20:52:21 UTC
confusing thing. search onto bing and yahoo. that will may help!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...