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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strcat help 1

Status
Not open for further replies.

frangac

Technical User
Feb 8, 2004
163
0
0
ZA
Hi All,

I am new with c and would like some help.
When reading a bin file the year is 06, the decimal value = 6 so I use the &rawtime to determine the year and then
cat it with the array (xya[j]) so that the result will printf 2006 and do this with the month as well as the day.
How can I strcat the "strncpy(datum,(char *)(ctime (&rawtime))+20,3);" (200) with the xya[j] array??????
Whenever I compile with gcc there are errors :
C.Fopen.c:170: warning: passing arg 2 of `strncat' makes pointer from integer without a cast
oC.Fopen.c:170: too few arguments to function `strncat'
What am I doing wrong or is there any other way to do this.

if(length < 10)
{
time (&rawtime);
if (xya[j]<10)
{
strncpy(datum,(char *)(ctime (&rawtime))+20,3);
datum[3]='\0';
}
else
{
strncpy(datum,(char *)(ctime (&rawtime))+20,2);
datum[2]='\0';
datum[3]='\0';
}
printf("XXXXX %s XXXXXX",datum);
strcat(datum,xya[j]);
// cat 200 with xya[j] (6) = 2006
}
//printf(" %d Len",length);
//printf("%x",xya[j]);
//printf(" Len %d ",length);

Many Thanks
Chris
 
Please use the [tt][ignore]
Code:
[/ignore][/tt]
tags when posting code.

> When reading a bin file the year is 06, the decimal value = 6
What if you read 99 ?

If your base is 2000, why bother to read the time, why not just
Code:
sprintf( datum, "%4d", 2000 + xya[j] );

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top