time_t data type-- what does start +1 mean?


 
Thread Tools Search this Thread
Top Forums Programming time_t data type-- what does start +1 mean?
# 1  
Old 09-14-2005
time_t data type-- what does start +1 mean?

Hi,
I am trying to understand an very old C program.

....
time_t start, end;
ptr = localtime(&start);
...
fprintf(out, "%-35s 01 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, start, mach_num,atoi(buffer), asctime(ptr));

fprintf(out, "%-35s 03 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, (start + 1), mach_num,atoi(buffer), asctime(ptr));
.....

what does (start+1) do here?
What about asctime(ptr)?



Thanks a lot!!

.
# 2  
Old 09-15-2005
May I make a suggestion? asctime() is part of the standard C library, so the man page
Code:
man asctime

will tell you everything you need to know.

start+1 just displays one more than the unsigned long value of start.
# 3  
Old 09-15-2005
Hi
I kind of understood the meaning for those two questions but just wanted to verify it.

Here is the my real problem:
When the below code running, sometimes the result of end-2 is greater than end -1, sometime it isn't.

Does anyone know what could be the reason?

Thanks a lot!


.....
time_t start, end;
.....
fprintf(out, "%-35s 55 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, end - 2, mach_num,atoi(buffer), asctime(ptr));

fprintf(out, "%-35s 50 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, (end - 1), mach_num,atoi(buffer), asctime(ptr));
# 4  
Old 09-15-2005
What you've posted so far doesn't give enough information. Are there any intervening lines between the two fprint() statements?

This looks like an attempt to check time sync on two different boxes.
# 5  
Old 09-15-2005
seconds after 1970

No, there is no intervening lines between the two fprint() statements.
But this is this : ptr = localtime(&end);

I know that this part of the code suppose to write to a log file format like below. But sometimes the number with blue color in the second line is lesser than the number with blue in the first line. The number should be the seconds after 1970. It happened randomlly.

6174 Name 55 20261 02 1110798898 1 5 /tty/M1/08 Mon Ma
r 14 06:15:00 2005
6174 Name 50 20261 02 1110798002 1 5 /tty/M1/08 Mon Ma
r 14 06:15:00 2005
===============================================





5514 Name 55 00000 03 1126647298 1 5 /tty/M1/03 Tue Sep 13 17:35:00 2005
5514 Name 50 00000 03 1126647299 1 5 /tty/M1/03 Tue Sep 13 17:35:00 2005

Last edited by whatisthis; 09-15-2005 at 11:04 AM.. Reason: addition
# 6  
Old 09-15-2005
Under some heavy-duty circumstances and with some versions of unix:
the order that data is written to a file may not be preserved. We had an old DEC-unix box that did that. I don't know that this is what you are seeing, but it's possible.

You can correct the problem with fflush():
Code:
fprintf(..........);
fflush(out);
fprintf(...........);

This has nothing to do with C in particular.
# 7  
Old 09-15-2005
Jim,
According to your reason: the difference between the first data and second data will be around 15 minutes behind. Could it be that long?
1110798898-1110798002=896 seconds

6174 Name 55 20261 02 1110798898 1 5 /tty/M1/08 Mon Mar 14 06:15:00 2005
6174 Name 50 20261 02 1110798002 1 5 /tty/M1/08 Mon Mar 14 06:15:00 2005



I am thinking maybe it's the parenthesis cause the trouble???
"end -2" without parenthesis calculated the time correctly.
But "end -1" with the parenthesis didn't calculated time correctly sometimes.

It doesn't make sense to me since I thought with the parenthesis should be getting the correct answer.

Does it really matter with parenthesis or without parenthesis?




fprintf(out, "%-35s 55 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, end - 2, mach_num,atoi(buffer), asctime(ptr));

fprintf(out, "%-35s 50 %5s %2s %10d 1 5 /tty/M%d/%02d %24s", buffer3, job, ver, (end - 1), mach_num,atoi(buffer), asctime(ptr));
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Incompatible data type fpos_t in C

This is from a program I wrote over in 1998 that I am trying to compile on a linux machine: void write_line (FILE *fp, int rec_no, line_rec *arec) { fpos_t woffset; woffset = (rec_no - 1) * sizeof(line_rec); fsetpos(fp,&woffset); fwrite(arec,sizeof(line_rec),1,fp); }On the line... (2 Replies)
Discussion started by: wbport
2 Replies

2. AIX

AIX and Value too large to be stored in data type.

root@test8:/config1>oslevel -s 5300-01-00-0000 root@test8:/config1>oslevel -r 5300-01 while moving a file sized 9GB i got this message root@test8:/configapp>mv bkp_14JUN16_oraapp_2.tgz /oraapp bkp_14JUN16_oraapp_2.tgz: Value too large to be stored in data type. possibly need APAR... (2 Replies)
Discussion started by: filosophizer
2 Replies

3. UNIX for Advanced & Expert Users

When did UNIX start using encrypted passwords, and not displaying passwords when you type them in?

I've been using various versions of UNIX and Linux since 1993, and I've never run across one that showed your password as you type it in when you log in, or one that stored passwords in plain text rather than encrypted. I'm writing a script for work for a security audit, and two of the... (5 Replies)
Discussion started by: Anne Neville
5 Replies

4. Programming

help with data type sizes

i'm using a C program and running it on a linux server, i got 2 adressess of 2 variables, and 2 addresses of 2 chars, and compared it. and got the size of a int and the size of a char. why is a size of a int (4 bytes) bigger then the size of a char (1 byte)? also if i do &a-&b i get 1, but if i... (30 Replies)
Discussion started by: omega666
30 Replies

5. Web Development

Data type to use for prices with commas

Hi everybody, I`m very new with PHP and Databases and I having the follow issue with prices data.. The original information is in CSV files. The prices have formatted with commas and dots as follow: 12,300.99 -->(thousands separated by commas) 3,500.25 -->(thousands separated... (10 Replies)
Discussion started by: cgkmal
10 Replies

6. Shell Programming and Scripting

Perl data type checking

I am using perl 5.8.0. I need to check some values to see it they are floats. Our system does not have Data::Types so I can't use is_float. Is there something else that I can use? The only thing in Data is Dump.pm. I am not allowed to download anything to our system so I have to use what I have.... (3 Replies)
Discussion started by: ajgwin
3 Replies

7. AIX

Value too large to be stored in data type???

Hello, I get this message : "Value too large to be stored in data type" when I try to open a 3Gb file. Can someone helps me to resolve the problem. Thank you very much (5 Replies)
Discussion started by: limame
5 Replies

8. Programming

data type limitation

I am writing some code to do analysis on the file system (HP-UX 11.11). I am using stat(..) to get file information. My problem is that the file-size may exceed the data types defined in 'sys/stat.h' & 'sys/types.h' respectively. Thus file-sizes in the Giga-byte range are not read correctly.... (2 Replies)
Discussion started by: ALTRUNVRSOFLN
2 Replies

9. Programming

FILE data type

Hi all, Can anyone tell me a little about the datatype FILE, which represents stream. What does its structure look like, and in which header file is it defined and so on... Ex : FILE *fp ; fp = fopen("filename", "w") ; (6 Replies)
Discussion started by: milhan
6 Replies

10. Programming

trouble handling time_t and struct tm

--- (6 Replies)
Discussion started by: runawayNinja
6 Replies
Login or Register to Ask a Question