K
Keith Thompson
Alan Peake said:Phil said:So scrap "char*str;" and "str=f", and use "char str[20];" instead.
Thanks Phil, that solved the problem. Hadn't realised that char *str
doesn't point anywhere but char str[20] allocates space for the array.
Program now compiles without errors.
Let me recommend again that you take a look at the comp.lang.c FAQ,
<http://www.c-faq.com/>. Question 7.1 is particularly relevant, but
it wouldn't hurt to read the whole thing. (Note that the sample code
uses gets(), which should *never* be used.)