|
I need to convert the following C code to RPG. I suppose I can leave the
getword() function as C, but I really need to be able to do the main()
function as RPG. Some help making this RPG would be great :)
#include <stdio.h>
void
getword (char *word, char *line, char stop)
{
int i, x, y;
for (i = 0; ((line[i] == stop) && (line[i]));)
{
x = 1;
y = 0;
while (line[y++] = line[x++]);
}
for (x = 0; ((line[x]) && (line[x] != stop)); x++)
word[x] = line[x];
word[x] = '\0';
if (line[x])
++x;
y = 0;
while (line[y++] = line[x++]);
return;
}
int
main ()
{
char array[] = "This is a test. And so is this.";
char *string;
string = (char *) malloc (sizeof (char) * (strlen (array) + 1));
printf ("array:\t%s\n", array);
while (array[0])
{
getword (string, array, ' ');
printf ("string:\t%s\n", string);
}
return (0);
}
James Rich
james@eaerich.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.