Dear Friends,
stuck again .... first let me give the code having no syntactical error but does not suffice the desire result.
-----------
char *HotName="HOT\0";
char *Extension="LOG\0";
printf("\n\n the OLD Name of file is %s \n\n ",HotName);
printf("\n\n the OLD Extension name is %s \n\n ",Extension);
if(CreateFile() != SUCCESS)
{
printf("\ncftodat. Process %d Error Creating the ERROR file ..\r\n",pid);
printf("\ncftodat. Process %d Terminating ..\r\n",pid);
exit(0);
}
printf("\n\n the file name is %s \n\n ",HotName);
printf("\n\n the Extension name is %s \n\n ",Extension);
strcat(HotName,Extension);
printf("\n\n the NEW Extension name is %s\n\n ",Extension);
printf("\n\n the file name after Extension concatination is %s \n\n ",HotName);
-----
int CreateFile()
{
char TmpDt[50], *tmpname, tmpname1[50] ;
tmpname = tmpnam(NULL);
sprintf(TmpDt,"%s %s",DATE,tmpname);
system(TmpDt);
ftemp = fopen(tmpname,"r");
if (ftemp == NULL)
{
printf("Error in the file ....\n\n");
exit(0);
}
fscanf(ftemp,"%s",tmpname1);
fclose(ftemp);
unlink(tmpname);
strcat(HotName,tmpname1);
return(SUCCESS);
}
-------
after running the program am getting the result as ...... OUTPUT...
the OLD Name of file is HOT
the OLD Extension name is LOG
the file name is HOT020729155246
the Extension name is 9155246 ---- wrong here .... should be only --- > LOG
the NEW Extension name is 915524691552469UNIX ---- wrong here .... should be HOT020729155246LOG
the file name after Extension concatination is HOT02072915524691552469UNIX ---- wrong here .... should be should be HOT020729155246LOG
the expected result is mentioned above ..... adjacent to the output..
Please help ..... find out where the error is ....
I am struggling with this since last 2 hours.
with best regards
Mehul Doshi