| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | reading input from stdin |
DV> char name[41];
DV> gets(name);
DV> name[41]='\0';
DV> printf("%s",name);
DV> My bad.
name only has 41 characters assigned to it,
name[0] to name[40].
You are still writing to name[41], which is out of bounds.
You need to remember that C uses 0-based arrays.
An array with three elements will have elements 0, 1, and 2.
> ] * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) |
|
| SOURCE: echomail via exec-pc | |
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™.