[Solved] C prog. Pointers and strings [closed]


In your first example, you MUST pass a char pointer for the "%s" modifier so it is actually the way it has to be, you would of course know that if you read the appropriate documentation, like e.g. The C Standard.

The second one, is wrong. Because it would invoke undefined behavior. To print the address of a variable you need to create a pointer to it with the & address of operator, or directly use the address of operator and the "%p" printf() specifier, any other specifier would cause undefined behavior.

Using the correct specifier, would work in your first example too.

2

solved C prog. Pointers and strings [closed]