Path: utzoo!mnetor!uunet!husc6!cmcl2!rutgers!iuvax!silver!creps From: creps@silver.bacs.indiana.edu (Steve Creps) Newsgroups: comp.lang.c Subject: When to use xalloc() when reading string values? Message-ID: <925@silver.bacs.indiana.edu> Date: 18 Feb 88 02:08:17 GMT Reply-To: creps@silver.UUCP (Steve Creps) Distribution: na Organization: Indiana University Computer Science Department Lines: 17 I'm running into a little confusion using strings in C, namely when should I allocate space for them? I would appreciate any hints or rules- of-thumb to use. The main problem I'm having is in a routine I'm writing which reads strings into fields of a struct type. The strings are of unknown length before I read them. Do I need to call an alloc() routine first? The problem with this is how can I know how much to allocate? Also, since they are returned by the routine, when should I free the space used for them? Thanks in advance, as they say. Disclaimer: I know quite a bit more about C than this question makes it sound. - - - - - - - - - Steve Creps on the VAX 8650 running Ultrix 2.0-1 at Indiana University. creps@silver.bacs.indiana.edu, ...iuvax!silver!creps, creps@iubacs.bitnet "Louisville Slugger baseball bats are made in Indiana"