Sponsored Content
Full Discussion: compile a c program
Top Forums Programming compile a c program Post 302169746 by jim mcnamara on Friday 22nd of February 2008 10:05:39 AM
Old 02-22-2008
It was easier to rewrite this than to explain the problems.
Code:
/*
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>
#include <errno.h>

int main(int argc, char **argv)
{
	struct tm *rettm;  /* use a pointer */
	time_t now=time(NULL);  /* add a value to now */
	char timebuf[128]={0x0}; /* place to park date time values */

	/* grab the first argument, time in seconds Note:  will segfault the old way*/
	if(argc < 2)   /* argc has to be > 1 */
	{ /* error */
		fprintf(stderr, "bad arguments -1\n"); /* you can also user perror() here */
		exit(1);
	}
	/* zero is a valid number and is valid for epoch seconds */
	errno=0;  /* set errno to a known state */
	if((now=atol(argv[1])) == 0 && errno !=0) /* atol never returns a NULL use argv */
	{ /* error */
	  /* you get to add errno checking here */
		fprintf(stderr,"invalid conversion -2\n"); /* you can also user perror() here */
		exit(1);
	}
	rettm=localtime(&now);  /* you can check for a NULL return here if you want */
	/* check your man page - some implementations only allow struct tm > Dec 13 20:45:52 UTC 1901. */
	/* use std library for time/date  use strftime */

	printf("%02d%02d%02d%02d\n", rettm->tm_mon+1, rettm->tm_mday, rettm->tm_hour, rettm->tm_min);
	strftime(timebuf, sizeof(timebuf),"%m %d %H %M %S", rettm);
	printf("%s\n", timebuf);

    return 0;
}

 

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
freealut-config(1)					      General Commands Manual						freealut-config(1)

NAME
freealut-config - script to get information about the installed version of freealut SYNOPSIS
freealut-config [ --prefix= DIR] [ --exec-prefix= DIR] [ --version ] [ --libs ] [ --cflags ] DESCRIPTION
freealut-config is a tool that is used to configure and determine the compiler and linker flags that should be used to compile and link progams, libraries, and plugins that use freealut. The use of freealut-config is deprecated. The more generic tool pkg-config should be used instead. OPTIONS
--cflags Print the compiler flags that are necessary to compile a program or library that uses freealut. --exec-prefix=DIR If specified, use DIR instead of the installation exec prefix that freealut was build with when computing the output for the --cflags and --libs options. This option must be specified before any of the --cflags and --libs options. --libs Print the linker flags that are necessary to link a program or library that uses freealut. --prefix=DIR If specified, use PREFIX instead of the installation prefix that freealut was built with when computing the output for the --cflags and --libs options. This option is also used for the exec prefix if --exec-prefix was not specified. This option must be specified before any of the --cflags and --libs options. --version Prints the currently installed version of freealut on standard output. EXAMPLES
gcc -o main.o $(freealut-config --cflags) -c main.c is how you might use freealut-config to compile a C source file for an executable program. gcc -o my_app $(freealut-config --libs) main.o util.o is how you might use freealut-config to link compiled objects into an executable program. SEE ALSO
pkg-config(1) This manual page was written for sdl-config by Branden Robinson, originally for Progeny Linux Systems, Inc., and the Debian Project. It was adapted to freealut by Sam Hocevar. freealut 2003-11-22 freealut-config(1)
All times are GMT -4. The time now is 11:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy