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
3
votes
1 answer

How to properly pass an array as a function argument?

When I try to send an array in to the function I get an error. This is my minunit test program: #include "minunit.h" #include "calc.h" #include int tests_run = 0; static char * test_Repetitve() { mu_assert("error in…
3
votes
1 answer

On Exception-Safety in a Function-Call

Is the call to f() exception-safe? inline std::auto_ptr auto_new() { return std::auto_ptr(new C()); } void f(std::auto_ptr p1, std::auto_ptr p2); // ... { f(auto_new(), auto_new()); } In other words, does it make any…
wilhelmtell
  • 57,473
  • 20
  • 96
  • 131
3
votes
2 answers

How do I change struct variables in a C function?

Basically, what I am trying to do is change struct variables inside a function. Here's the code: int weapon_equip(struct player inventory, int in) { int x = in - 1, y; int previous_wep[4]; //Stores the values of the previous equipped…
octagonlord69
  • 75
  • 2
  • 2
  • 6
3
votes
1 answer

Stack Overflow from Missed Function Call

I'm sorry if this is posted elsewhere (I can't find anything, as my problem is rather specific), but I understand (or least in theory) what the error is; I am having trouble on how to fix it. The code is supposed to show how merge sort works; The…
Astix
  • 31
  • 1
3
votes
4 answers

Why can a Num act like a Fractional?

As expected, this works fine: foo :: Fractional a => a foo = undefined -- datum bar :: Num a => a -> a bar a = undefined -- function baz :: Fractional a => a baz = bar foo -- application This works as…
3
votes
3 answers

Why do C Functions Alter Arrays Automatically?

I'm learning C, and I was just curious as to why C functions, when given arguments like int, char, double etc., don't change the values of those arguments when called, but when they are passed array arguments, they do alter array elements. For…
Harambe17
  • 175
  • 7
3
votes
1 answer

Are "array" and "&array[0]" completely interchangeable?

Yes, it has been asked before, many times, but I wanna know which one is more advisable? typedef struct { int a; int addr[8]; } usr_command; usr_command* p_usr_command; int foo(int* parameter) {} So which one is less prone to be…
3
votes
1 answer

Call a function in C++ by its address without knowing the return type

I want to call a C function from a C++ dll by its address. I know how to do it where the return type is known from this separate question: Calling a function through its address in memory in c / c++. However, if I do not know the return type, what…
user1910744
  • 180
  • 2
  • 12
3
votes
3 answers

Counting the number of function calls in an executable

I am trying to find the exact number of function calls to one of my implemented C function inside my code. The project includes several C files. What is the easiest solution to figure out how many times a function is called during the execution of…
A23149577
  • 2,045
  • 2
  • 40
  • 74
3
votes
2 answers

why would I call a function with the function name wrapped in parens?

I recently came across code that looked like this: void function(int a, int b, int c){ //... } int main(){ //... (function)(1,2,3); //... } What is the point of wrapping the function name separately in parens? Does it have any affect…
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
3
votes
3 answers

How to determine if a function has been called in Powershell

I have a Big Script where i want to ignore a function call if it has been called already. Am having a flag which is set to determine this now. But how do i do this without needing to have a flag or count for this. Thanks!
3
votes
4 answers

How to use default arguments in php

I want to define a function doSomething(arg1, arg2) with default values to arg1=val and arg2=val When I write function doSomething($arg1="value1", $arg2="value2"){ // do something } Is it possible now to call doSomething with default arg1 and…
liysd
  • 4,413
  • 13
  • 35
  • 38
3
votes
1 answer

How to call the functions of an other element contained inside template (ShadowDOM)?

The question is simple (I hope so). Is there a way to call the function myFunctA of my-elementA from my-elementB? Or any solution that works similarly to how public functions work in Java or C?