Home > Article > Backend Development > Why Does \"25\" 1 Output \"5\" in C ?
The Unexpected Concatenation of Strings and Numbers in C : Exploring "456" 1
The code snippet
#include <iostream><br>int main()<br>{</p> <pre class="brush:php;toolbar:false">std::cout << "25"+1; return 0;
}
poses a perplexing question: why does the expression "25" 1 output "5" instead of an expected "26"? To unravel this mystery, let's delve into the inner workings of this code.
In C , string literals like "25" are not treated as true strings but as character arrays. In the example given, "25" is equivalent to a character array {'2', '5', '
The above is the detailed content of Why Does \"25\" 1 Output \"5\" in C ?. For more information, please follow other related articles on the PHP Chinese website!