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
Compilation problem Cyr1us AIX 1 05-05-2009 11:40 AM
Problem on Pro*C compilation on HP-UX asutoshch UNIX for Advanced & Expert Users 5 04-29-2009 12:52 PM
Pro C Compilation problem ajaysahoo AIX 0 02-06-2009 02:05 AM
compilation problem phani_sree High Level Programming 2 10-25-2007 05:18 PM
compilation problem mansoorulhaq SUN Solaris 0 10-19-2007 09:18 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-14-2009
on9west on9west is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 14
C Compilation problem

Dear all

I am new to C programming

In response to the post

cat get_time.c

Code:
#include <stdlib.h>
#include <sys/time.h>
main()
{
     struct timeval tv;
     struct timezone tz;
     struct tm *tm;
     gettimeofday(&tv, &tz);
     tm=localtime(&tv.tv_sec);
     printf(" %d:%02d:%02d %d \n", tm->tm_hour, tm->tm_min,
              m->tm_sec, tv.tv_usec);
     exit(0);
}

gcc get_time.c

Code:
get_time.c: In function `main':
get_time.c:9: warning: assignment makes pointer from integer without a cast
get_time.c:10: error: dereferencing pointer to incomplete type
get_time.c:10: error: dereferencing pointer to incomplete type
get_time.c:11: error: `m' undeclared (first use in this function)
get_time.c:11: error: (Each undeclared identifier is reported only once
get_time.c:11: error: for each function it appears in.)

I am new to C....and really no idea. Please hint me for that.

Many thanks
Valentino
  #2 (permalink)  
Old 10-14-2009
julianjensen julianjensen is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 5
I seem to recall that you need

#include <time.h>

instead of (maybe in addition to)

#include <sys/time.h>
  #3 (permalink)  
Old 10-14-2009
homeboy homeboy is offline
Registered User
  
 

Join Date: Oct 2009
Location: China
Posts: 4
first: you should add the header #include<time.h>
second:you made a little mistake

Code:
printf(" %d:%02d:%02d %d \n", tm->tm_hour, tm->tm_min,
              m->tm_sec, tv.tv_usec);

no m was defined,it's tm
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:32 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0