I have a code, and the error keeps saying usage: ./a.out <integer value>
. I looked online for two days to see how to fix it, but I could not find any concrete answers. If someone could tell me what it means, and how I can fix it, that would be wonderful.
-
5Please include your code as text not as image – Ackdari Apr 06 '20 at 17:38
-
4It's to tell you that you need to provide an integer argument when you run the program. – Weather Vane Apr 06 '20 at 17:38
-
Please see [What does `int argc, char *argv[]` mean?](https://stackoverflow.com/questions/3024197/what-does-int-argc-char-argv-mean) – Weather Vane Apr 06 '20 at 17:43
-
2You need to run the program as `./a.out N`, where `N` is some non-negative integer value (e.g., `./a.out 1` or `./a.out 100` or `./a.out 12345`). – John Bode Apr 06 '20 at 20:14
1 Answers
It means that when you run your program you will have run it in the command line with an argument:
./ program_name(a.out) integer_value
^^^^^^^^ ^^^^^^
program argument
Where program_name
is the name you gave your program when you compiled it, if you do not provide one it's default name will be a.out
for linux based systems and a.exe
for Windows.
integer_value
is an argument you must use, otherwise the condition if(argc != 2)
will evaluate to true and the program will exit showing you that message, which is part of the program.
argc
is part of the main function's arguments and it represents number of arguments, including the program name, you use when executing the program.
argv
is also part of the main function's arguments and is an array of strings in which argv[0]
is the program name, argv[1]
is the actual argument (if you have more arguments it continues, argv[2]
, etc.).
To answer your question, the program is fine, it doesn't need fixing, it just needs to be correctly executed. Open a command window/terminal, navigate to the directory where the executable is located an execute it as explained.
BTW, the code should be posted as text, not images.
You can learn more about command line arguments in What does int argc, char *argv[] mean?

- 23,467
- 7
- 28
- 53