• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Solved K and R page 22 question about array program.


Active Member

Thanks: 5
Messages: 104

It says that the output of this program on itself is ........

Is there a way to run the .c textfile through the executable of the program on the command line without useing the int argc, char **argv?

Eric A. Borisch

Well-Known Member

Thanks: 204
Messages: 313

In general, there are three basic ways for a program to get input: files (this includes stdin), arguments (argv/argc), and environment variables (getenv(3)). How you use those are up to you, but environment variables tend to be for things that are specific to the machine or, ahem, environment, that don’t change from run to run. Arguments tend to be about what to do or how to do it, and often include file names, and the files themselves (stdin and out/err included) provide the data to operate on and where to put the result.

There are of course more (sockets, shared memory) but as you are starting out, those are the big three.