Questions tagged [function-call]

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

A function call is a line of code that executes a specific block of code defined as a function, that is, self-contained code that may optionally take arguments, defined for the purpose of code reuse.

760 questions
5
votes
1 answer

Perl function call confused me

A perl function call confused me, could anyone help me? catFiles called like this: catFiles( \@LINKFILES => "$output_prefix.links" ); catFiles function define: sub catFiles { unlink("$_[1]") if(exists $_[1]); system qq( cat "$_" >> "$_[1]"…
user1744416
  • 171
  • 1
  • 12
5
votes
3 answers

Stumped by one line of Python

I'm unofficially doing a python course CS61A through Berkely, and I'm absolutely stumped by one simple assignment that requires me to provide only one expression at the very end of the provided template. Here is the problem code: # HW 4 Q5. (fall…
5
votes
1 answer

Calling Nt function from ntdll.dll in Win32 environment, C++

I want to call some Nt function from ntdll.dll, I'm doing that like this above. For calling: NtTestAlert() , you need typical ntcall kernel routine, accessable via int 2Eh. ( from here I got Nt functions http://undocumented.ntinternals.net/ ) Code…
user1131997
4
votes
4 answers

How do I create an std::vector of functions without defining the functions explicitly?

I want to create an std::vector object (or any other standard or custom container type) with elements of custom and arbitrary functions whose signatures are all the same. It should be something like this: // Define the functions and push them into a…
hkBattousai
  • 10,583
  • 18
  • 76
  • 124
4
votes
6 answers

My factorial function is not returning factorial

I am not able to find out why my function returns the user input only rather then the factorial of the input. #include #include int factorial(int x) { //int x; int sum = 1; while (x!=0){ sum = sum * x; …
4
votes
3 answers

Bubble sort not working when I implement it in a function

I have this code to order a group of teams based on their scores, just like a soccer ranking and the code works fine when implemented like this (btw I defined "NEQS" to 18): int melhor_class(t_equipa *eqA, t_equipa *eqB) { if(eqA->pontos >…
4
votes
4 answers

Can I call a function taking a long parameter with an int argument?

Is this code undefined behavior? extern long f(long x); long g(int x) { return f(x); } According to the C11 standard, in 6.5.2.2 §6: If the function is defined with a type that includes a prototype, and [...] the types of the arguments after…
Pierre
  • 1,942
  • 3
  • 23
  • 43
4
votes
2 answers

What are the advantages of using "{}" for casting in C Language?

I am trying to understand why use this casting style in ProcessHacker Code. RtlSetHeapInformation( PhHeapHandle, HeapCompatibilityInformation, &(ULONG){ HEAP_COMPATIBILITY_LFH }, // HEAP_COMPATIBILITY_LFH = 2UL …
Adam
  • 51
  • 5
4
votes
2 answers

Passing an array as function argument without defining a variable

How can we pass an array directly to a function in C? For example: #include void function(int arr[]) {}; int main(void) { int nums[] = {3, -11, 0, 122}; function(nums); return 0; } Instead of this, can we just write…
4
votes
2 answers

Getting all values from an Enum, when values are callables in Python 3.7

I have an Enum class in Python 3.7 defined as such: # activation functions def relu(x: float) -> float: return x * (x > 0) def sigmoid(x: float) -> float: return 1 / (1 + math.exp(-x)) class Activation(Enum): SIGMOID = sigmoid …
SamuelNLP
  • 4,038
  • 9
  • 59
  • 102
4
votes
1 answer

Ambiguous member template lookup

An answer to this question says in the following code: #include using std::vector; struct foo { template void vector(); }; int main() { foo f; f.vector(); // ambiguous! } The last line in main is ambiguous,…
Destructor
  • 14,123
  • 11
  • 61
  • 126
4
votes
2 answers

Why global variable is different from local variable in this function?

Here I have a function named max(a,b) to get the max number out of two. And I found that the value of variable a and b using printf() are different after executing printf("maxab()=%d after max: a=%d b=%d \n",max(a++,b++),a,b); when a and b are…
walle
  • 129
  • 1
  • 9
4
votes
2 answers

Brackets in Haskell function call

I'm struggling to remember how to use brackets when calling Haskell functions. I come from a C-style background and I'm used to f(comma, separated, args) syntax for calling functions. Apparently this is the same as (in Haskell) ((((f) comma)…
Zoey Hewll
  • 4,788
  • 2
  • 20
  • 33
4
votes
1 answer

Is there a let / flet / labels like concept for binding closures to avoid funcall?

Whilst going over let over lambda I happened across (defmacro! dlambda (&rest ds) `(lambda (&rest ,g!args) (case (car ,g!args) ,@(mapcar (lambda (d) `(,(if (eq t (car d)) t …
cheshirecatalyst
  • 379
  • 1
  • 5
  • 14
4
votes
3 answers

What is the return value from a function without a return statement?

#include int sel=5,out=10; int findout(){ if(sel==5) return out*=2; } int main(){ int ret1,ret2=-1; ret1=findout(); printf("before %d %d %d",sel,out,ret1); sel=8;out=7; ret2=findout(); printf("\nafter…