| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | gcc2 |
Bill Patterson wrote in a message to All: BP> I'm using gcc2 2.5.8 on the Hobbes RTR Nov 1994 CD. BP> I'd use emx except I can't get it to run. Anyways, gcc works BP> (mostly) great. I do have one little problem though. When I BP> use gets() I get a error when I try to run my program. BP> Printed on the screen is a message saying gets() is BP> unstable. What is a suitable bit of code to use that I can BP> substitute for gets(). I've tried all sorts of work arounds BP> using getchar() and getc(). I can't seem to properly detect BP> the end of the input string (a EOF or a CR). Could some one BP> punch in a brief example of a gets() routine? The problem is that gets() is inherently unstable because it was defined that way in the C language, and its use in new code is to be deprecated. There is no way for a caller to notify gets() about the length of the buffer available to it, and therefore no way for gets() to be sure that it does not overrun that buffer. The preferred solution is to use fgets() on the stdin FILE object, since this function takes an argument that specfies the size of the buffer. There are subtle differences in the behavior of gets() and fgets(), particularly that gets() strips the newline character and fgets() preserves it. In fact, if the string returned from fgets() does not end with a newline character, this is the signal that fgets() stopped because it reached the end of the buffer rather than because of the end of input. This is, however, a general C programming issue, not specific to OS/2. BP> Even better, is there a way to use newer libraries with gcc BP> that might have a fixed gets()? GCC/2 is no longer supported. The EMX package is recommended and supported. -- Mike ---* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107) SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407 SEEN-BY: 712/515 628 704 713/888 800/1 7877/2809 @PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.