× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Lim,

Sorry, I did not cut and paste the code correctly in my OP. Below is
what the code looks like

I can't see anything wrong with your code, and indeed, I tried it on my own system, and did not have the problem you've described. However, since the code you posted wasn't a complete program, I had to add some code to make it work (maybe that makes it different)?

What Simon says is true, of course. But, I'm not sure that it applies to your situation, since you stated that you were calling it with the following command (this is a copy/paste from your message):

CALL PGM(*LIBL/RUN_ECDSTP) PARM('NOCC07QA' '5553' '*LIBL' UA_STP3)

Since all of your parms are literals on the command-line, and not variables from another program, they should all be null-terminated properly. And, indeed, when I ran your code, I didn't see any garbage.

Here's the code I test with:


#include <stdio.h>
#include <string.h>
#include <time.h>


int get_time_stamp(char sString[])
{
time_t thetime;
struct tm *usetime;
char sTime[20];

time(&thetime);
usetime=localtime(&thetime);
sprintf(sTime,"%02d/",usetime->tm_mon+1);
sprintf(sTime+3,"%02d/",usetime->tm_mday);
sprintf(sTime+6,"%4u ", usetime->tm_year + 1900);
sprintf(sTime+11,"%02d:",usetime->tm_hour);
sprintf(sTime+14,"%02d:",usetime->tm_min );
sprintf(sTime+17,"%02d",usetime->tm_sec );
strcpy(sString,sTime);
return(1);
}


void
printThis(char *text)
{
char stime[20];

memset(stime, 0x0, sizeof(stime));
get_time_stamp(stime);
printf("%s %s\n", stime, text);
}


int main(int argc, char **argv) {

char printThisBuf[110];

sprintf(printThisBuf, "argv[0]->%s\n", argv[0]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[1]->%s\n", argv[1]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[2]->%s\n", argv[2]);
printThis(printThisBuf);

sprintf(printThisBuf, "argv[3]->%s\n", argv[3]);
printThis(printThisBuf);

return 0;
}


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.