| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Borland Strings 2/2 |
JK> -> JK> Only problem is, I don't see how this is going to help you JK> -> JK> in case of a string that you simply don't know in advance JK> -> JK> what size it will be. It's a Catch-22; either you must get JK> -> Yes, you do. fgets, and you can decree how long it will be. JK> JK> You don't understand. fgets() still requires the programmer to give a size to JK> the string BEFORE the user inputs the information. That's what I'm trying to JK> avoid. I want the users input to determine the string size. Apparently C JK> doesn't allow you to do that... name a language that allows this! there is a way around this though.. char *string,*buffer; buffer= malloc(1024 * sizeof(char)); fgets(buffer,1024,infile); string=calloc(strlen(buffer) * sizeof(char)); strncpy(string,buffer,strlen(buffer)-1); /*gets rid of trailing \n */ free(buffer); * KWQ/2 1.2i NR * If at first you don't succeed, put it out for beta test. --- PCBoard (R) v15.21/M 10* Origin: Programmers Guild BBS (1:244/317) 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: 244/317 300 400 250/702 3615/50 396/1 270/101 105/103 42 712/515 @PATH: 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™.