LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-28-2008, 05:02 AM   #1
sarathius
LQ Newbie
 
Registered: Jan 2008
Posts: 12

Rep: Reputation: 0
how to call a function inside switch case


can anyone tell me how to call a function inside switch case in linux programming?
 
Old 01-28-2008, 05:06 AM   #2
Uncle_Theodore
Member
 
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 60
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.
 
Old 01-28-2008, 05:07 AM   #3
evoc
LQ Newbie
 
Registered: Dec 2007
Location: La Spezia, Italy
Distribution: Ubuntu
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by sarathius View Post
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();
}
 
Old 01-28-2008, 05:21 AM   #4
sarathius
LQ Newbie
 
Registered: Jan 2008
Posts: 12

Original Poster
Rep: Reputation: 0
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();
}
 
Old 01-28-2008, 05:36 AM   #5
evoc
LQ Newbie
 
Registered: Dec 2007
Location: La Spezia, Italy
Distribution: Ubuntu
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by sarathius View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot use copy_to_user inside the open() sys call routine archieval Programming 4 05-26-2007 09:09 AM
function calls inside a function manas_sem Programming 2 02-28-2007 01:27 AM
function defn inside a function in C...!!! arunka Programming 1 02-05-2006 01:08 AM
problem on dynamic function call inside a class! antony_csf Programming 0 06-29-2004 10:15 PM
system() function in nested if else/case! natalinasmpf Programming 10 01-26-2004 06:52 AM


All times are GMT -5. The time now is 04:32 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration