Sponsored Content
Full Discussion: compile a c program
Top Forums Programming compile a c program Post 302169728 by djehresmann on Friday 22nd of February 2008 08:49:55 AM
Old 02-22-2008
one more

One more compile. I have not worked with these programs in a couple of years. This is is giving the error below. If I change to

main
int main
void main

it does not seem to help.


"get_date_from_secs.c" 44 lines, 834 characters
/*
Listing 6 get_date_from_secs.c
get_date_from_secs.c
pass the number of seconds since
the Epoch, and return a Gregorian
date argument
use "%02d" date format.

*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
char *secarg;
struct tm rettm;
time_t now;

/* grab the first argument, time in seconds */
if((secarg = *++argv) == NULL)
{ /* error */
printf("-1");
exit(1);
}
else
{
if((now=atol(secarg)) == NULL)
{ /* error */
printf("-2");
exit(1);
}
else
{
rettm=*localtime(&now);
/*printf("%s", asctime(&rettm));*/
/*printf("%2d/%d/%d", rettm.tm_mon+1, rettm.tm_mday, rettm.tm_year+1900);*/
printf("%02d%02d%02d%02d", rettm.tm_mon+1, rettm.tm_mday, rettm.tm_hour, rettm.tm_min);


/usr/local/bin> gcc get_date_from_secs.c -o get_date_from_secs
get_date_from_secs.c: In function 'main':
get_date_from_secs.c:28: warning: comparison between pointer and integer
 

10 More Discussions You Might Find Interesting

1. Programming

how to compile a program

how do i go about compiling a simple hello world script in mandrake linux? this is something i have had no luck in finding on the main site, please help? thank you (2 Replies)
Discussion started by: CmpKillr
2 Replies

2. Programming

How to compile a c program by using gcc

Hi all, Yeasterday I try to compile c program by using cygwin. I just find an errors the fist one is concerinig about the end of the line. To summit my Assignment which is the day after tommorow I have to compile my c program by using just gcc. If any one know what do I have to... (5 Replies)
Discussion started by: Bell
5 Replies

3. Programming

how to compile a program statically

how can i do static compilation in cc and -lldap i have system defined and user defined header file. Can any one suggest any site where from i can get some information about static and dynamic compilation. Thankx (1 Reply)
Discussion started by: bhakti
1 Replies

4. BSD

How to compile a c program in freeBSD

Hi , I have freeBSD installed. I need to compile a c program which has embedded informix sql statement in it. Can you please help me to to do the same. I need to know what I should I do to make BSD compatable to compile the c program ? Thanks in advance Jisha (3 Replies)
Discussion started by: jisha
3 Replies

5. Programming

Compile c program on Sun Solaris OS

Can anyone tell me how to compile a c programs on SunSolaris OS 5.1 Version as gcc and cc are not working Thanks!!!! (4 Replies)
Discussion started by: shivu
4 Replies

6. Programming

compile a program in C with teradata sentences using cc

hi, I want to compile a program in C. It have a multiple calls to teradata. I have no idea how to compile in Aix. The compiler that I should be use is cc. I tried cc -G -KPIC tdsfbd0358.c this generates a tdsfbd0358.i and after I have no Idea what I have to make, a link? how?... (3 Replies)
Discussion started by: kajum
3 Replies

7. UNIX for Advanced & Expert Users

compile a c program in a encrypted way

Hi Guys, I wonder I had have a look to the cc compile options but I could be missing one but basically I'm compliling a c program where I will storing a command to connect to a database and also userid and password. The issue is that after the module is generated using a command like strings I... (14 Replies)
Discussion started by: arizah
14 Replies

8. Programming

Not able to compile C program on z/OS (USS)

Hi, I having an issue while compiling a C program in USS (z/OS) machine. I was able to create objest files (.o) from source (.c) files but when I try to create a binary file from the object files I am getting the below error. $ cc util.o sock.o app.o -lnsl -o ptf FSUM3067 The archive... (7 Replies)
Discussion started by: madhu84
7 Replies

9. UNIX and Linux Applications

Cannot compile/install gnu program

Hello, I'm trying to install ansifilter which is a program that translates ansi text to HTML. The idea is to install it on AIX 7.1 but is failing. All de appropriate gcc libraries and requirements for this software were installed successfully, but when I do the gmake I get the following... (4 Replies)
Discussion started by: bazajav
4 Replies

10. Programming

How to compile and run the ProC (*.pc) program?

Hi Team, I am very new to this forum and hope someone will help me in resolving the issue. I am new to Pro C also. I made some changes to the existing Pro C program and want to run the program with the changes. But I am unable to neither compile nor run the program. Please do the... (2 Replies)
Discussion started by: prakashs1218
2 Replies
mktime(3C)						   Standard C Library Functions 						mktime(3C)

NAME
mktime - converts a tm structure to a calendar time SYNOPSIS
#include <time.h> time_t mktime(struct tm *timeptr); DESCRIPTION
The mktime() function converts the time represented by the tm structure pointed to by timeptr into a calendar time (the number of seconds since 00:00:00 UTC, January 1, 1970). The tm structure contains the following members: int tm_sec; /* seconds after the minute [0, 60] */ int tm_min; /* minutes after the hour [0, 59] */ int tm_hour; /* hour since midnight [0, 23] */ int tm_mday; /* day of the month [1, 31] */ int tm_mon; /* months since January [0, 11] */ int tm_year; /* years since 1900 */ int tm_wday; /* days since Sunday [0, 6] */ int tm_yday; /* days since January 1 [0, 365] */ int tm_isdst; /* flag for daylight savings time */ In addition to computing the calendar time, mktime() normalizes the supplied tm structure. The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to the ranges indicated in the definition of the structure. On successful completion, the values of the tm_wday and tm_yday components are set appropriately, and the other components are set to represent the specified calendar time, but with their values forced to be within the appropriate ranges. The final value of tm_mday is not set until tm_mon and tm_year are determined. The tm_year member must be for year 1901 or later. Calendar times before 20:45:52 UTC, December 13, 1901 or after 03:14:07 UTC, January 19, 2038 cannot be represented. Portable applications should not try to create dates before 00:00:00 UTC, January 1, 1970 or after 00:00:00 UTC, January 1, 2038. The original values of the components may be either greater than or less than the specified range. For example, a tm_hour of -1 means 1 hour before midnight, tm_mday of 0 means the day preceding the current month, and tm_mon of -2 means 2 months before January of tm_year. If tm_isdst is positive, the original values are assumed to be in the alternate timezone. If it turns out that the alternate timezone is not valid for the computed calendar time, then the components are adjusted to the main timezone. Likewise, if tm_isdst is zero, the origi- nal values are assumed to be in the main timezone and are converted to the alternate timezone if the main timezone is not valid. If tm_isdst is negative, mktime() attempts to determine whether the alternate timezone is in effect for the specified time. Local timezone information is used as if mktime() had called tzset(). See ctime(3C). RETURN VALUES
If the calendar time can be represented in an object of type time_t, mktime() returns the specified calendar time without changing errno. If the calendar time cannot be represented, the function returns the value (time_t)-1 and sets errno to indicate the error. ERRORS
The mktime() function will fail if: EOVERFLOW The date represented by the input tm struct cannot be represented in a time_t. Note that the errno setting may change if future revisions to the standards specify a different value. USAGE
The mktime() function is MT-Safe in multithreaded applications, as long as no user-defined function directly modifies one of the following variables: timezone, altzone, daylight, and tzname. See ctime(3C). Note that -1 can be a valid return value for the time that is one second before the Epoch. The user should clear errno before calling mktime(). If mktime() then returns -1, the user should check errno to determine whether or not an error actually occurred. The mktime() function assumes Gregorian dates. Times before the adoption of the Gregorian calendar will not match historial records. EXAMPLES
Example 1 Sample code using mktime(). What day of the week is July 4, 2001? #include <stdio.h> #include <time.h> static char *const wday[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "-unknown-" }; struct tm time_str; /*...*/ time_str.tm_year = 2001 - 1900; time_str.tm_mon = 7 - 1; time_str.tm_mday = 4; time_str.tm_hour = 0; time_str.tm_min = 0; time_str.tm_sec = 1; time_str.tm_isdst = -1; if (mktime(&time_str)== -1) time_str.tm_wday=7; printf("%s ", wday[time_str.tm_wday]); BUGS
The zoneinfo timezone data files do not transition past Tue Jan 19 03:14:07 2038 UTC. Therefore for 64-bit applications using zoneinfo timezones, calculations beyond this date may not use the correct offset from standard time, and could return incorrect values. This affects the 64-bit version of mktime(). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe with exceptions | +-----------------------------+-----------------------------+ SEE ALSO
ctime(3C), getenv(3C), TIMEZONE(4), attributes(5), standards(5) SunOS 5.11 1 Nov 2003 mktime(3C)
All times are GMT -4. The time now is 06:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy