Questions tagged [function-parameter]

The function parameters are the variable names, listed in the definition of the function.

In many programming languages, parameters are the essence of the functions. The function parameters define the variable names, listed in the definition of the function. They are often confused with (and referred to as) function arguments, which actually are the real values that are passed to and received by the function when it is being called.

314 questions
0
votes
0 answers

Implementing out and ref parameters in powershell

I have the C# class class ConfigurationPropertyBag : IPropertyBag { internal HybridDictionary properties; internal ConfigurationPropertyBag() { properties = new HybridDictionary(); } public void Read(string propName, out…
user3417479
  • 1,830
  • 3
  • 18
  • 23
0
votes
5 answers

how to create a function to tell me if a statement throws an exception or not in c#

I'd like to have a function take a statement as a parameter, either as a string or as some other type that I'm not aware of, and return true if the execution of that statement throws an exception, and false otherwise. This may rely on some sort of…
user420667
  • 6,552
  • 15
  • 51
  • 83
0
votes
1 answer

Error using fzero for f=(x.^3).*cos(x) in a loop

I try to find all the roots of the function f=(x^3)*cos(x) between -6pi and 6pi using fzero. I create a function: function y3=f(x) f=(x^3)*cos(x); end % Then at the command window: syms x; fun=@f x1=-6*pi; x2=-5*pi; r=zeros(1,12); for i=1:12 …
0
votes
0 answers

Pass the array to function in bash script - array_name[@]: command not found

I have to pick a random data in several arrays. So I made a function that takes over the array and returns a random value. This is my code, ./pick_data.sh pick_random_data() { # seed random generator RANDOM=$$$(date +%s) #take array as…
YEEN
  • 67
  • 1
  • 5
0
votes
1 answer

Swift: Passing a class method as a function parameter (instead of a generic function)

I'm trying to call a function on a root view controller from a popover view controller. The function below works but it seems there should be a better way: func doSomethingInRoot() { if let appDelegate = UIApplication.shared.delegate as?…
SuperCodeBrah
  • 2,874
  • 2
  • 19
  • 33
0
votes
3 answers

Default NULL in function declaration

Why do we need declare $slug argument as default NULL in the function? What will change if we won't declare it default NULL? It looks for me like nothing would change: public function view($slug = NULL) { $data['news_item'] =…
0
votes
4 answers

Using function parameter as variable

Is it bad or good practice or maybe undefined behavior to re-assign function parameter inside function? Let me explain what I'm trying to do with an example, here the function: void gkUpdateTransforms(GkNode *node /* other params */) { GkNode…
recp
  • 383
  • 1
  • 2
  • 14
0
votes
1 answer

Proper way to use javascript scope with expressjs in node

I'm trying to learn JavaScript and full-stack development and I can't quite wrap my head around how to use express with JavaScript properly .... my question goes like this : in every tutorial iv'e seen online the following syntax is being used…
Gal Ratzkin
  • 124
  • 2
  • 8
0
votes
1 answer

passing struct array as parameter to a function

I am trying to set a array of structure in a array of structure. to this i have created a function. how ever i try it i am not able to do it. struct polygon { struct point polygonVertexes[100]; }; struct polygon polygons[800]; int polygonCounter =…
Naseeruddin V N
  • 597
  • 5
  • 17
0
votes
1 answer

C++ function parameters wont compile

So I have a function with the prototype double Solution::bisect ( double xLeft, double xRight, double epsilon, double f(double x, EquCoeffs coeffsStruct), bool &error ); where function f is prototyped like this double…
Bassinator
  • 1,682
  • 3
  • 23
  • 50
0
votes
0 answers

Function with parameter list without variable name

The following code is very basic and obvious: void PrintParameter(int i, char c) { std::cout << i << std::endl; } If I do this: PrintParameter(5, 'A'); I get 5 as expected and because I don't use the parameter c no error occurs. Now I think in…
user7140484
  • 920
  • 6
  • 14
0
votes
3 answers

Using pointers or references to struct

Me and my friend is using structs in our code (our code is separate from each other). Lets take the following example: struct Book { char title; int pages; } void setBook(struct Book *tempBook) { tempBook->title = "NiceTitle"; …
0
votes
1 answer

What's this usage of the variable cast to void in function body?

I am just learning to code embedded C. I see some code like below. The function is defined like this: void printDebug(const char d1[]){(void)d1;} And it is used like this: printDebug("BLE_UART_EVENT"); I don't understand its purpose. It gives me…
smwikipedia
  • 61,609
  • 92
  • 309
  • 482
0
votes
1 answer

Supplied parameter to the function becomes NULL?

I wrote a recursive function to reverse a linked list as follows: struct node{ int val; struct node *next; }; //Global pointer to structure struct node *start=NULL,*head=NULL; //*Function to input node* void create(int data){ struct node…
Vivek Shankar
  • 770
  • 1
  • 15
  • 37
0
votes
1 answer

C++ error: double free or corruption (fasttop) while working with dynamic arrays

The following code gives me an error: double free or corruption (fasttop): class Matrix{ public: Matrix(); Matrix(int size, int *&a); ~Matrix(); friend ostream &operator <<(ostream &out, const Matrix M1); …