Ask Your Question
4

What causes a character pointer to print the entire character array, while an integer pointer does not have the same behavior?

asked 2023-07-09 22:42:33 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2023-07-09 23:11:01 +0000

plato gravatar image

A character pointer prints the entire character array because it is designed to treat the input as a string of characters and print until it hits a null character ('\0') indicating the end of the string. On the other hand, an integer pointer treats the input as a sequence of integers and only prints the value of the integer it points to. It would require a loop to print the entire integer array pointed to by the integer pointer.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-09 22:42:33 +0000

Seen: 9 times

Last updated: Jul 09 '23