LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to call a function inside switch case (https://www.linuxquestions.org/questions/programming-9/how-to-call-a-function-inside-switch-case-616815/)

sarathius 01-28-2008 05:02 AM

how to call a function inside switch case
 
can anyone tell me how to call a function inside switch case in linux programming?

Uncle_Theodore 01-28-2008 05:06 AM

What programming language do you use? All by itself, calling a function is not platform-specific, so it's the same in Linux or any other OS.

evoc 01-28-2008 05:07 AM

Quote:

Originally Posted by sarathius (Post 3037421)
can anyone tell me how to call a function inside switch case in linux programming?

Code:

int var,res;
scanf("%d",var);
switch(var){
  case 1:  res = doThis();
  case 2:  res = doNotThis();
  default: res = doNoneOfThis();
}


sarathius 01-28-2008 05:21 AM

I have write the program as follows. still it shows error like "too few arguments to function". can anyone rectify this

int i;
scanf("%d",&i);

switch(i)
{
case 1:
add_provider();
}

evoc 01-28-2008 05:36 AM

Quote:

Originally Posted by sarathius (Post 3037441)
I have write the program as follows. still it shows error like "too few arguments to function". can anyone rectify this

int i;
scanf("%d",&i);

switch(i)
{
case 1:
add_provider();
}

probably you have to send parameters to add_provider(), cause generally add_* needs something to add :)


All times are GMT -5. The time now is 08:35 PM.