| | |
I have few question
Thread Solved |
•
•
Join Date: Aug 2008
Posts: 3
Reputation:
Solved Threads: 0
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;
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
•
•
Join Date: Jun 2007
Posts: 59
Reputation:
Solved Threads: 3
•
•
•
•
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;
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...
•
•
Join Date: Aug 2008
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
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...
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??
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.
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.
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
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
![]() |
Similar Threads
- C command-line I/O question (C++)
- Apache Alias Directive... mod_alias question (Linux Servers and Apache)
- Completely new to C++ and have question about using char (C++)
- Question (Geeks' Lounge)
- question on cooling (Cases, Fans and Power Supplies)
- Context-sensitive grammar question :( (Computer Science)
- Welcome PC Mod Kingdom peeps! (Geeks' Lounge)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
- Changing Network Configuration (*nix Software)
Other Threads in the C Forum
- Previous Thread: extract max-min value from every column in array
- Next Thread: fibonacci
| Thread Tools | Search this Thread |
#include * adobe ansi array asterisks binarysearch centimeter changingto char character cm convert copyimagefile cprogramme creafecopyofanytypeoffileinc database dynamic execv feet fgets file floatingpointvalidation fork function getlogicaldrivestrin givemetehcodez global grade gtkwinlinux hacking histogram ide inches include incrementoperators infiniteloop input interest intmain() iso kernel keyboard kilometer license linked linkedlist linux list locate looping lowest match matrix meter microsoft number oddnumber opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprograming socketprogramming standard strchr string suggestions systemcall test threads turboc unix urboc user variable voidmain() wab whythiscodecausesegmentationfault windowsapi






