× 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 Erik,

I guess I don't understand the issue. What problems does it cause to cast the parameters? Unfortunately, you've run into a limitation of the C language. It expects all of the arguments passed to main() to be in a single array... Which means they all have to be defined as the same data type.

I don't really understand the problem, though... what's wrong with doing this?

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

char *userid, *code;
int *custno;

if (argc != 4) {
fprintf(stderr, "Need 4 parameters!\n");
exit(1);
}

userid = argv[1];
code = argv[2];
custno = (int *)argv[3];

return do_work(userid, code, *custno);
}

Sure, the casting is slightly cumbersome, but certainly less so than writing the main() in another language and binding. I guess I don't understand the complaint...

I would not do anything else in main(), however, besides interpret the parameters and then call another routine with them... Otherwise, things start to get too ugly.


Olsson Erik wrote:
I want to submit a call to a program in batch, and the program needs to take
a number of parameters.
If this was an interactive application I'd create the called program as a
service program, have a prototyped interface for controlling parameters and
all would be fine.

Any better solutions than having the program called via SBMJOB to have a
main function and then manually typecast the parms from argv's char * to
their proper ones (say integers)?

Thanks in advance.


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.