I have few question

Thread Solved

Join Date: Aug 2008
Posts: 3
Reputation: m_banerjeein is an unknown quantity at this point 
Solved Threads: 0
m_banerjeein m_banerjeein is offline Offline
Newbie Poster

Re: Hi Its Mithun

 
0
  #1
Aug 12th, 2008
Hi All

Guys few quick questions on C..

1. What does "static void <function_name>(argument1,argument2)" means..

2. Whether this would give a compilation error if i write this piece of code...

int a =1 , b=2,c=3 ;
(a=b)=c;
Last edited by m_banerjeein; Aug 12th, 2008 at 6:07 am. Reason: To make 1st question more clear
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 59
Reputation: Chaster is an unknown quantity at this point 
Solved Threads: 3
Chaster Chaster is offline Offline
Junior Poster in Training

Re: Hi Its Mithun

 
-1
  #2
Aug 12th, 2008
Originally Posted by m_banerjeein View Post
Hi All

Guys few quick questions on C..

1. What does "static void <function_name>(argument1,argument2)" means..

2. Whether this would give a compilation error if i write this piece of code...

int a =1 , b=2,c=3 ;
(a=b)=c;
Well,
static means (at least in Java, but I think it's the same) that you don't need to create an instance of that class, you can access that method directly: ClassName.methodName([params]).
void means that your function is actually a "procedure" and will not return any value
arguments are the values you pass to your function

The piece of code is illegal in Java, I don't know whether it's correct in C. sorry...
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 3
Reputation: m_banerjeein is an unknown quantity at this point 
Solved Threads: 0
m_banerjeein m_banerjeein is offline Offline
Newbie Poster

Re: Hi Its Mithun

 
0
  #3
Aug 12th, 2008
Originally Posted by Chaster View Post
Well,
static means (at least in Java, but I think it's the same) that you don't need to create an instance of that class, you can access that method directly: ClassName.methodName([params]).
void means that your function is actually a "procedure" and will not return any value
arguments are the values you pass to your function

The piece of code is illegal in Java, I don't know whether it's correct in C. sorry...
Well this is a piece of code in C only...

1. I have only the problem in understanding the return type.

Is this that function is static to the file where i will be using??
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: I have few question

 
0
  #4
Aug 12th, 2008
1) static is a scope operator that limits the scope of the function to the *.c file in which it is declared. If you have two *.c files, each file could contain a function with the same name as long as the function is declared static. IMO its poor programming to have two functions like that, but it is possible.

2) compile it and find out what happens.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,602
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: I have few question

 
0
  #5
Aug 12th, 2008
i know you are asking about functions, but an important thing about static, is that when you scope a local variable as such, it will retain its value across repeated calls to the function where it is declared. this is very important when creating functions, espeically if they are intended to be imported into larger projects.

you can also make a static global variable that will retain its value and be visible to all functions with the *.c file, but no functions anywhere else, much like how DRAGON described the static-scoped function
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 13
Reputation: gautam610 has a little shameless behaviour in the past 
Solved Threads: 3
gautam610 gautam610 is offline Offline
Newbie Poster

Re: Hi Its Mithun

 
0
  #6
Aug 13th, 2008
2) This is an L-value error that u have to put a reference that have a legal address at the left side of assignment operator at the equal sign..........
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,602
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 120
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: I have few question

 
0
  #7
Aug 13th, 2008
BANERJEEEIN,

what DRAGON said... compile it and find out.

how hard is that?
Last edited by jephthah; Aug 13th, 2008 at 4:56 am. Reason: oops!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC