Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with compilation problem

Status
Not open for further replies.

anatazi

Programmer
Jun 24, 2002
33
US
Hi everyone,
I get a funny message whe I compile the program below.
ld:
Object file format error in: time.h: read_cur_obj_info: bad file magic number(0x7473)

Here is the code, Please point me to any errors that I am making.
Thanks
#include<stdio.h>
#include&quot;time.h&quot;

struct TIME {
int hours;
int minutes;
int seconds;
};
typedef struct TIME Time;

Time get_time();
void printt(Time);
int pftime();

void main(void)
{
Time t;

t = get_time();
printt(t);
printf(&quot;the totoal number of seconds is %i\n&quot;, pftime(t));
}

#include &quot;time.h&quot;

int pftime(Time parm)
{
int t_n_s;
t_n_s = ((3600 * parm.hours) + (60 * parm.minutes) + parm.seconds);
return t_n_s;
}

#include&quot;time.h&quot;
#include<stdio.h>

Time get_time()
{
Time parm;

printf(&quot;Please enter hours: &quot;);
scanf(&quot;%i&quot;, &parm.hours);

printf(&quot;Please enter minutes: &quot;);
scanf(&quot;%i&quot;, &parm.minutes);

printf(&quot;Please enter seconds: &quot;);
scanf(&quot;%i&quot;, &parm.seconds);
}

#include&quot;time.h&quot;
#include<stdio.h>

void printt(Time t)
{
printf(&quot;%i : %02i : %02i&quot;, t.hours, t.minutes, t.seconds);
}
 
You might have a problem with your instalation of C. That is a linker error as far as I can say, and it refers to a broken object or library.
What C compiler are you using? [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
why do you have your includes strewn all over your program (between each function). The time structure is already declared within <time.h>. Are you are using a self made header file &quot;time.h&quot;. When you have an include within double quoytes the compiler looks for the header file in the same directory as your program exec.

try this..

#include <time.h>
#include <stdio.h>

int main (void)
{
struct tm today;
time_t time_in_secs;

time_in_secs = time(NULL); /* for todays date */
today =*localtime(&time_in_secs);

printf(&quot;Date %02d/02d/02d\n&quot;,today.tm_mday,today.tm_mon+1,
today.tm_year-100);
printf(&quot;Time %d:%02d:%02d &quot;, today.tm_hour, today.tm_min, today.tm_sec);
return 0;
} Hoping to get certified..in C programming.
 
Hi again,
To Nosferatu, I am actually working in Unix, I use cc.

To Bigtamscot, The reason that I have #include in every function is that each function is in a separate file and they use printf which requires a #include<stdio.h>.
I am using #include&quot;time.h&quot; because I am using my own time.h file.
 
What OS are you on?

And what is your filenaming convention for the names of the files in this project? ______________________________________________________________________
Did you know?
The quality of our answers is directly proportional to the number of stars you vote?
 
This just could be the problem... try renaming your header file, as there is one system header file called time.h.
It may cause problems. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Got it all fixed, was compiling .h file.
Sorry for the confusion.
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top