Re: stream io in c



Ron Ford <ron@xxxxxxxxxxxxxxx> wrote:

On Thu, 31 Jul 2008 01:26:25 +0000, Richard Heathfield posted:

Ron Ford said:

FILE *fp;
char name[]="text58.txt";

fp=&name;

question. What on earth do you think this assignment means? Why did you
type it? (Answering that question might be the most important way you can
learn from this thread.)

LHS is a pointer. Since I could not create a sensical thingamajig of type
FILE--everything I tried was a syntax error--I tried chars. There's no
guarantees on pointers like this; why would there be a prohibition?

That's a nice example of magical thinking. "This looks, in one trivial
detail, like that; therefore, this should work, in all essentials, like
that." No. A pointer to FILE and a pointer to array of char are quite
different, and what's much more important, a FILE and an array of char
are very different. If you want to be a programmer, you must learn to
make sure that you _know_, rather than guess.

Richard
.



Relevant Pages

  • Re: Problem with va_ macros and arrays of arrays
    ... > the arrays passed to a ... > specific char, somewhat similar to what the standard function ... that with an array of struct, or possibly a pointer to a dynamic array ... > As I'm still a beginner in C without a copy of the standard I ...
    (comp.lang.c)
  • Re: Difference between Char* ptr and char arrCh []
    ... I have a few queries regarding array of characters using array ... notation and pointer notation. ... Is there a difference in storage of global char* and char* inside ...
    (comp.lang.c)
  • Re: Returning pointer to array problem II
    ... Iam trying to make program were I enter string and serach char. ... and funktion prints out witch position char is found this is done if funktion serach_char. ... so far all good what I want do next is: return, from funktion, pointer value to array were positions is stored. ...
    (comp.lang.c)
  • Re: Simple question on Pointers
    ... int main ... It stores 12 char and only 12 ... pointer to the first element of the array with type pointer to element ...
    (microsoft.public.vc.language)
  • Re: char **argv & char *argv[]
    ... "pointer to pointer to char". ... >> pointer)) pointing to the first element of an array. ... so we have to start adding more context. ... type "pointer to char", rather than "array MISSING_SIZE of char". ...
    (comp.lang.c)