The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 01-11-2007
Registered User
 

Join Date: Oct 2006
Location: Switzerland
Posts: 8
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;
}
}
Reply With Quote
Forum Sponsor
  #2  
Old 01-11-2007
Registered User
 

Join Date: Oct 2006
Location: Switzerland
Posts: 8
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?
Reply With Quote
  #3  
Old 01-11-2007
Registered User
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 979
Quote:
Originally Posted by heck
ok...
Take a look at the snippets below.
What does it mean a construct like:
void function()
type var;
{
funct code...
}
Code tags for code please. They make them readable as opposed to, not.

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...
}
I'll translate the rest:
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;
  }
}
Reply With Quote
  #4  
Old 01-11-2007
Registered User
 

Join Date: Feb 2005
Posts: 53
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.
Reply With Quote
  #5  
Old 01-11-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
Quote:
Originally Posted by Corona688
This is an old, depreciated method of declaring functions. Like, really old -- I only see it in code from the 80's.
Actually, the C compiler that comes with HP-UX allows only this method.

Writing this:
Code:
void do_fsmon(fsnode *curnode)
produces a clear error saying that ANSI C type declarations are not supported (or some such - don't have access to HP C right now).

Due to this, I end up writing all my functions like this:
Code:
void do_fsmon(curnode)
fsnode* curnode;
Reply With Quote
  #6  
Old 01-12-2007
Registered User
 

Join Date: Oct 2006
Location: Switzerland
Posts: 8
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0