Questions tagged [argc]

The number of arguments given to the program, found as a parameter to main in some languages, notably C.

argc stands for argument count, and represents the number of arguments given to the program, or main, in a command-line. It is used in conjunction with .

Keep in mind that argc also counts the program name.

Notable Stack Overflow questions:

243 questions
2
votes
3 answers

There's something from stdin or not?

It's possible to make a code that recognizes whether a file was passed like: program.out < file.dat I search an answer for this because I want to write code to do something like this: int main (int argc, char *argv[]) { char filename[50]; …
ᴜsᴇʀ
  • 1,109
  • 2
  • 9
  • 23
2
votes
2 answers

Passing command line inputs to Processing language exported application/applet?

I have created a processing application and then exported it using file->export application. Initially some of the parameters were hard coded to simply make it run. Now I want to supply these (string) parameters using command line while executing…
tod
  • 1,539
  • 4
  • 17
  • 43
2
votes
1 answer

Passing arguments to executable from command line

I'm trying to pass arguments to a Fortran executable from the command line. A sample program that achieves this in C is (taken from here): #include int main (int argc, char *argv[]) { int count; printf ("This program was called with…
seb
  • 2,251
  • 9
  • 30
  • 44
2
votes
1 answer

Enumerate console parameters (argv) in CMake

I want to parse/process passed console parameters in CMake, so that if I run this in console: cmake -DCMAKE_BUILD_TYPE=Release -DSOME_FLAG=1 .. I want to obtain the -DCMAKE_BUILD_TYPE=Release and -DSOME_FLAG=1 from this inside CMake script (and…
dreamzor
  • 5,795
  • 4
  • 41
  • 61
2
votes
1 answer

OpenCV argc and argv confusion

I'm checking some OpenCV tutorial and found this line at the beginning (here is the link, code is under the CalcHist section http://opencv.willowgarage.com/documentation/c/histograms.html) if (argc == 2 && (src = cvLoadImage(argv[1], 1)) != 0) I've…
Moirae
  • 139
  • 3
  • 14
2
votes
5 answers

Checking to make sure argv[1] is an integer c++

For my program I have to make sure the user only inputs a positive INTEGER. for example if the user inputted 12hi it should not run the program and print to std error. I am not quite sure how to implement this. int main(int argc, char *argv[]) …
Ryan Mann
  • 53
  • 1
  • 10
1
vote
3 answers

Segmentation Fault With argv

I have a program that reads in a single argument from the command line and performs certain operations on it. I'm using argv and argc. When I fail to pass an argument to the program, it segfaults. I've tried checking if argc isn't a certain value…
wafflesausage
  • 295
  • 5
  • 14
1
vote
0 answers

Writing custom atoi() function

I am trying to write a c code that mulplies two numbers and I wrote a custom atoi() function to convert char to int. I tried running the exe file with the following arguments ./exe 2 3 but it giving me a result of 0 instead of 6 and I can't seem to…
1
vote
4 answers

Selective suppression of output to the terminal C++.

I have a bunch of .cpp files which together process similar data files but of various sizes. For the larger data files I want to do some timing studies on the functions inside the .cpp files. I would like to suppress the output the results for…
smilingbuddha
  • 14,334
  • 33
  • 112
  • 189
1
vote
1 answer

Attempting to understand multithreading which involves struct. Getting output "Segmentation fault (core dumped)"

I created this program to understand multithreading and have tested this program with single thread and works. Basically you enter 3 digits. First one as an initiale number, Second one is how many squence it will be run and last number is used for…
1
vote
2 answers

Why to put argc argv arguments in main when they never accessed?

I often see programs where people put argc and argv in main, but never make any use of these parameters. int main(int argc, char *argv[]) { // never touches any of the parameters } Should I do so too? What is the reason for that?
Kaiyakha
  • 1,463
  • 1
  • 6
  • 19
1
vote
1 answer

I would like to know what's wrong with this tiny code that it doesn't provide the expected results

In short, the purpose behind this program is to loop through the given array of strings and print it out as is after changing any Comma (,) to Colon(:). int main(int argc, string argv[]) { int i; int j; int n; int x; int count = 0; …
Cap4
  • 13
  • 3
1
vote
1 answer

How to return argc in assembly

I'm trying to return argc in assembly but the program returns 0. I'm using GNU 2.28 on Windows 10 ! There is my code: .section .text .globl main main: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax movl %ebp, %esp popl %ebp …
Aphaistos
  • 11
  • 1
1
vote
2 answers

How do I dynamically allocate multiple strings from the command line argv?

For this assignment I'm supposed to grab multiple names from the command line arguments which are prefaced with either '+' (which inserts the name into my linked list) or '-' (which removes the name from the list), so if I were to enter "+bill +jim…
1
vote
0 answers

Sending file directory from one function to another

In this programme I want to ask the user to enter the file path of the image, this takes place in the main function. However the open file takes place in another function. To get the variable (location) to communicate between both functions, I…
EMAROH
  • 11
  • 2