Questions tagged [function-calls]

Function (or method) calling is the act of using a function or a method.

Functions (or methods) are blocks of code.
They are there, ready to perform some action (a sequence of instructions, including the possibility of calling other functions - even themselves, which is called recursion).
If nobody calls them, the are useless (dead code).

351 questions
-1
votes
2 answers

Executing bound std::function throws std::bad_function_call

I want to bind a member function to a std::function. I heard that member functions take one extra parameter which is the instance pointer. Therefore I call std::bind(&Class::Function, this, parameter) but when I execute the function…
danijar
  • 32,406
  • 45
  • 166
  • 297
-2
votes
1 answer

order of constructors called in a function

I would like to ask for a clarification of the constructors calls order in the following program. What I tried: The output starts with 1 3 2. I tried to debug it to see why the function "f" calls the 3rd argument's ctor before the 2nd's and I don't…
-2
votes
4 answers

Shifting pointer to some address by calling another function

Why in this code the pointer shifts to another location: #include void f(int *p) { int j=2; p=&j; printf("%d\n%p\n%d\n",*p,&j,p); } int main(void) { int *q; int m=98; q=&m; f(q); …
Gaurav
  • 201
  • 1
  • 11
-2
votes
2 answers

Return address buffer from one file to another

I have two files: mainfile.c and kmeans.c. I want to return the addresses of the buffers that are allocated in kmeans.c back to mainfile.c. The following is the process: kmeans.c void kmeans(int *cluster_assign, int *cluster_size,){ …
Don
  • 393
  • 3
  • 12
-2
votes
1 answer

Control Flow of if statement and function calls

I am getting the output ' 0,1,2,0'. Please someone help me how this function call is working. I have this doubt that after decrementing n, if statement will not execute as it will not be greater than 0. Thus there will be no output. But the result…
-2
votes
1 answer

Expected expression error with `[]`

My prototype for the function int ConvertUserColorToInteger(char [][7] , char [] ); int main (void) { This is my definition of the Function char COLOR_CODES[10][7] = {"black", "brown", "red", "orange", "yellow", "green", "blue",…
-2
votes
1 answer

Using constructor call as function parameter

Is it a good idea to use constructor calls as arguments? E.g. something like doSomething(ClassA(someConstructorParameter)); Will the object be destroyed when the function terminates? Or if you have a function that takes a char* and you don't want…
Kackao
  • 1,181
  • 3
  • 13
  • 22
-2
votes
1 answer

Compiler strangely trying to call another function (constructor) than intended

Hiho, I have implemented a singleton class in C++ which has got a problem with an initialization within its constructor where I try to initialize a member with a custom constructor but instead the compiler thinks I want to call the default…
robbepop
  • 119
  • 10
-2
votes
2 answers

usage of scanf inside while test condition

I want to store a series of integers till i press an enter in an array.How can i implement that Input: 1(tab space)2(tab space)3(tab space)4(tab space)enter i tried doing this #include main() { int i,j,c,d; int a[5]; for(i=0;i<2;i++){ …
sarat
  • 185
  • 9
-2
votes
4 answers

call function using yes or no

I want to convert an amount in Ringgit Malaysia to its equivalent value in USD. And I want to write a C program that could ask the user to enter yes or no to continue subsequent function. I have done some coding #include #include…
-2
votes
4 answers

Passing 2D array by value doesn't work

I am trying to pass a 2d array to a function. I don't want the actual array to be modified. So pass it by value. But my actual 2darray is getting modified.(when i modify myArray, x is getting modified). Why is it so? int main(int argc, const char*…
-2
votes
3 answers

strange error in passing pointers (*&) in constructor

i'm not a c++ guru at all, and i've tried to replicate this error in variuos little trials. the fact is that when i do a little program with 2 o 3 classes with what i wanto to do, there is no error. but in the main applicaiton i'm tring to write the…
nkint
  • 11,513
  • 31
  • 103
  • 174
-3
votes
2 answers

c/c++ | int * excepted, int given (returning a pointer??)

So I am making a program to find the max possible substraction. If n is, f.e 9284, the minimum number which can be made with the digits of 9284 is 2489 and the maximum one is 9842. the function max_substraction returns 9842 - 2489 as output. The…
Caitiff
  • 47
  • 3
  • 11
-3
votes
1 answer

Can anyone help me how to call this function parameter from class to be displayed in my output

This coding where I used function overloading is a code where user have to input their pointer for 4 subjects and its credit hour so it prints out their GPA. The thing is I have 3 parameter in Student(string test123, string nama, string vinto ). But…
-3
votes
2 answers

I want to call my function with string parameter

void GenerateDecryptedData("/home/merve/merve.enc", "/home/merve/merve.dec","dEneMe!1234"); I want to call my function like dEneMe!1234. void GenerateDecryptedData(const char* pathToEncryptedFile, const char*…
someWhereElse
  • 15
  • 2
  • 6
1 2 3
23
24