Argument-passing may refer to two different things: (1) the process of providing a program being started with some initial pieces of information (the arguments) on its command line; (2) the process of providing the initial values (the arguments) for the parameters of a function when it is called.
Questions tagged [argument-passing]
777 questions
2
votes
5 answers
Passing multi-dimensional arrays in C
I am currently trying to learn C and I have come to a problem that I've been unable to solve.
Consider:
#include
#include
#include
#define ELEMENTS 5
void make(char **array, int *array_size) {
int i;
char *t…
Mark
2
votes
2 answers
Strange behavior passing bound method to function
I believe that func(obj.attr) and tmp = obj.attr; func(tmp) should be completely indistinguishable. However, the following code
class Cls(object):
#@staticmethod
def f(self):
pass
def who(obj):
print(id(obj) % 1000, end='…

Huazuo Gao
- 1,603
- 14
- 20
2
votes
4 answers
Threading on a list of arguments
I would like to pass a list of values and have each of them passed as an independent Thread:
For example:
import time
import threading
list_args = [arg1, arg2, arg3, ...., argn]
# Code to execute in an independent thread
import time
def…

Bob R
- 605
- 1
- 13
- 25
2
votes
2 answers
Python pass in variable assignments through a function wrapper
So I know that you can wrap a function around another function by doing the following.
def foo(a=4,b=3):
return a+b
def bar(func,args):
return func(*args)
so if I then called
bar(foo,[2,3])
the return value would be 5.
I am wondering is…

Tim McJilton
- 6,884
- 6
- 25
- 27
2
votes
1 answer
Is it possible to pass argument via method reference?
I have the following code line:
MyClass{
Runnable job;
...
}
and inside one of the method:
this.job = myImporter::importProducts;
Now importProducts is method without arguments:
public void importProducts() {
...
}
But I need…

gstackoverflow
- 36,709
- 117
- 359
- 710
2
votes
1 answer
`Cannot convert 'char(*)[50]' to 'char**' for argument '1' to 'void prac(char**)'` when passing a 2D array to a function
I wanna pass 2D char array to function.
However, an error comes:
Cannot convert 'char(*)[50]' to 'char**' for argument '1' to 'void prac(char**)'
How can I fix the code ? Please help me.
Code:
#include
using namespace std;
void…

appleJuice
- 137
- 2
- 4
- 9
2
votes
3 answers
calling function with lesser number of arguments in C?
I strangely found that C allows linking of function where argument list doesn't match:
//add.c
int add(int a, int b, int c) {
return a + b + c;
}
//file.c
int add (int,int); //Note: only 2 arguments
void foo() {
add(1,2);
}
I compiled add.c…

Vivek Agrawal
- 113
- 11
2
votes
1 answer
Possible ways to control code in DLL
I am working on my university project and stuck with a problem.
My task is to write a program and .dll to intercept calls from WinAPI.
For example I launch my program and it should inject .dll using SetWindowsHookEx to any process by PID. I…

Giuseppe Baldinini
- 55
- 8
2
votes
4 answers
how to pass argument to main method in eclipse?
I am trying to pass parameter to a java class main method I want to pass parameter using eclipse so I went to
run -> run configuration -> program arguments
and I wrote my arguments
exp grammar
But whenever I run it gives me this error,
Exception…

Halawa
- 1,171
- 2
- 9
- 19
2
votes
1 answer
How to send a variable between two C programs
I have a C program, xyz.c which does some computations on a certain variable, say transferme. I want to transfer this variable/ pass this variable to another C program, say jkl.c.
I have been trying to do the following:
Fork the xyz.c and use…

complextea
- 393
- 1
- 5
- 16
2
votes
3 answers
Pass a template method as an argument
Could some one help me how to implement this code?
I need to pass a function to another function:
std::cout << process_time(Model::method1) << std::endl;
This function gets the function as a template type and calls it on an object
template…

zahmati
- 1,261
- 1
- 10
- 18
2
votes
2 answers
Writing a Nested shell script- Unable to pass argument
I am trying to create a shell script using another script.
Following is the code.
#!/bin/bash
count=$#
cat << EOF > /tmp/kill_loop.sh
#!/bin/bash
while true;
do
for i in "$@"
do
echo $i
done
done
EOF
When I see kill_loop.sh ,…

ambikanair
- 4,004
- 11
- 43
- 83
2
votes
3 answers
Pass function outputs as arguments to another function
I need to pass the output of a function in Python as an argument to another function. The only catch is that the 1st function returns a tuple and the entire tuple needs to be passed to the second function.
For ex:
I have a library function:
def…

Piyush
- 606
- 4
- 16
- 38
2
votes
1 answer
How to pass arguments when extending a jQuery method?
I'm trying to modify .offset() so that it never returns undefined, i.e. for invisible/hidden elements.
The problem that I'm having with that is that I don't know how to properly pass this to the original method, to be honest. Breakpoint-debugging…

WoodrowShigeru
- 1,418
- 1
- 18
- 25
2
votes
1 answer
C++ - Function pointer with arbitrary number of args
I'm trying to make a CPP function that takes a function pointer and an arbitrary number of arguments, adds some coordinates, then calls the function pointer as such:
int func_api(void(*fun)(int, int, ...args), ...args) {
fun(this.x, this.y,…

Jean-Luc Nacif Coelho
- 1,006
- 3
- 14
- 30