![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how i prepare a c++ code(c code) for implementing my own protocol format | amitpansuria | High Level Programming | 1 | 09-06-2007 08:09 PM |
| pause? where art thou? | 01000101 | High Level Programming | 3 | 05-15-2006 04:42 PM |
| SSH key code versus server key code | Texan | Security | 1 | 04-12-2006 08:57 AM |
| Return code from PL/SQL Code | Shaz | UNIX for Advanced & Expert Users | 7 | 06-03-2003 07:56 AM |
| waht's resume password for router | Yeliu | IP Networking | 1 | 09-19-2002 08:06 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Waht does thou mean, old C code
ok...
Take a look at the snippets below. What does it mean a construct like: void function() type var; { funct code... } hmmm.. i dont get it. my compiler either. void log_message(filename,message) char *filename; char *message; { FILE *logfile; logfile=fopen(filename,"a"); if(!logfile) return; fprintf(logfile,"%s\n",message); fclose(logfile); } void signal_handler(sig) int sig; { switch(sig) { case SIGHUP: log_message(LOG_FILE,"hangup signal catched"); break; case SIGTERM: log_message(LOG_FILE,"terminate signal catched"); exit(0); break; } } |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
sorry
sorry guys my "c" compiler gots it, i was too quick asking, i tried compile on C++ compiler.
But anyway i've never seen sth. like that, help me quick? |
|
#3
|
|||
|
|||
|
Quote:
This is an old, depreciated method of declaring functions. Like, really old -- I only see it in code from the 80's. This snippet is equivalent to: Code:
void function(type var)
{
funct code...
}
Code:
void log_message(char *filename, char *message)
{
FILE *logfile;
logfile=fopen(filename,"a");
if(!logfile) return;
fprintf(logfile,"%s\n",message);
fclose(logfile);
}
void signal_handler(int sig)
{
switch(sig) {
case SIGHUP:
log_message(LOG_FILE,"hangup signal catched");
break;
case SIGTERM:
log_message(LOG_FILE,"terminate signal catched");
exit(0);
break;
}
}
|
|
#4
|
|||
|
|||
|
Your code is Kernighan & Ritchie (K&R) dialect of C.
Now we are using Ansi C. Conversion between them is possible with protoize/unprotoize. Last edited by odys; 01-12-2007 at 09:16 AM. |
|
#5
|
||||
|
||||
|
Quote:
Writing this: Code:
void do_fsmon(fsnode *curnode) Due to this, I end up writing all my functions like this: Code:
void do_fsmon(curnode) fsnode* curnode; |
|
#6
|
|||
|
|||
|
Thanks a lot
Thanks a lot folks. I mean i assumed it to be like this. But i can assume everything. now i know it. Thank you!
K&R cool. Poor HP-UX developers, but you get used to nearly everything. |
|||
| Google The UNIX and Linux Forums |