I have a small function in the r.le programs that works fine under
SunOS 4.1.3 on my Sparcstation, but fails under Solaris 2.* and on
other machines. The function uses getchar and strcat to get user
digital input from the screen and dump it into an array. Here is
a typical statement to read digits and append them to the end of
a character array called "num":
while ((c=getchar()) && isdigit(c)) strcat(num, &c);
Earlier, Changyong Cao told me that this fails under Linux, since
strcat(num, &c) appends a bunch of strange characters instead of
just one. He found that the following substitution works:
while ((c=getchar()) && isdigit(c)) strncat(num, &c, 1);
While I will probably do this substitution and hope for the best,
I wonder if anyone knows why this happens or whether there is a
more general solution. Also, for some reason on some machines
my function only reads a couple of digital characters, then stops.
Anyone know why?
Bill Baker
bakerwl@uwyo.edu