Re: No error message when format string is passed as variable to printf functions family

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



But why is indirection done when string is defined as an array and not
when it is a pointer to constant string?

There is no indirection in the array case. A char array
declaration with an initializer defines exactly one object:
the array whose value is the string.

    const char one_object[] = "abc";

A char pointer definition with an initializer, on the other
hand, defines two objects: the pointer and the string it
points to.

    const char* const two_objects = "abc";

or equivalently:

    const char* const two_objects = one_object;

Martin





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux