+13

Why output is "ouch" ?

I don't know why a==b is true. https://code.sololearn.com/cx5qt0lux4pF/?ref=app

3/22/2019 8:16:56 PM

Pedro H.J

8 Answers

New Answer

+10

Let's elaborate it a bit : When we decade a string on this manner : char* word = "World without L"; // Now that string is an array of characters and every single element can be accessed in this way : first : *word second : *(word + 1) third : *(word + 2) And so on, every time we add a number it increments the address but when you simple use : word, it will display the entire word(unless you increment it permanently using pre and post increment) In the above example we are checking the equality of just the first character, so the output is ouch.

+12

Both *a and *b are 'c' (first char of char array), so they're equal

+10

Use "if (a==b)" to get "awesome"

+7

Makes sense. Thank you so much.

+3

its simply because the adresses pointed have the same datatype char

+2

Beacuse https://code.sololearn.com/c02SExhee290/?ref=app

+1

makes sense

+1

Because a and b are char so they consider only c as initial value so they are equal