rtnMichael
Programmer
Hey guys, I think I've been looking at this code for too long, but I have a simple question for you. ok, I have a pre-defined structure I want to pass into a subroutine. I need to fill the structure in the sub, then use it outside the sub afterwards. How would I go about doing it in the right way. Here's what I have:
struct TokenHeader strttimestamp;
sub()
{
...
...
if (!(GetTimeStamp(strttimestamp)))
return(1);
...
...
}
static int GetTimeStamp(strttimestamp)
struct TokenHeader *strttimestamp;
{
FILE *strttimestamp_fp;
if(!(strttimestamp_fp = fopen(timestamp_path, "rb"))
{
LogIt(1,FLAGIT,"%s: Unable to read %s file.", process_name, timestamp_path);
return(0);
}
if(fread((char *)&strttimestamp, 1, 12, strttimestamp_fp) <= 0)
{
LogIt(1,FLAGIT,"Can not read file %s - %s", timestamp_path, strerror(errno));
fclose(strttimestamp_fp);
return(1);
}
fclose(strttimestamp_fp);
return(0);
}
Thanks
M
struct TokenHeader strttimestamp;
sub()
{
...
...
if (!(GetTimeStamp(strttimestamp)))
return(1);
...
...
}
static int GetTimeStamp(strttimestamp)
struct TokenHeader *strttimestamp;
{
FILE *strttimestamp_fp;
if(!(strttimestamp_fp = fopen(timestamp_path, "rb"))
{
LogIt(1,FLAGIT,"%s: Unable to read %s file.", process_name, timestamp_path);
return(0);
}
if(fread((char *)&strttimestamp, 1, 12, strttimestamp_fp) <= 0)
{
LogIt(1,FLAGIT,"Can not read file %s - %s", timestamp_path, strerror(errno));
fclose(strttimestamp_fp);
return(1);
}
fclose(strttimestamp_fp);
return(0);
}
Thanks
M