|
jon wrote: > >> I wouldn't say to *never* use strtok, but you had better know what it > >>does before using it. > >While Jim is correct in absolute terms, and it _is_ important to know how >the function works, I wouldn't worry about it too much. Why? > >Because the best way to use strtok with RPG IV is to code the proto to pass >a pointer by value and use options(*String) as I demonstrated in the Redbook >example of using strtok. The other reason for avoiding strtok() is that it is not re-entrant. But since RPG programs are not re-entrant anyways, that's not a valid reason for not using strtok(). On the other hand, since strtok() uses a static internal variable, you cannot use strtok() multiple times within a nested loop. The best way to avoid problems is to just use the C run-time function strtok_r() instead. Cheers! Hans Hans Boldt, ILE RPG Development, IBM Toronto Lab, boldt@ca.ibm.com
As an Amazon Associate we earn from qualifying purchases.
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.