I know that C & C++ both are different languages, today I make a little typo in the following program but the program compiles fine on various C++ compilers (g++,clang,MSVC++)
Consider following program:
int main()
{
int s[]={3,6,9,12,18};
int* p=+s; // Observe this strange looking initialization due to use of unary + operator
}
The above program compiles fine in C++ (See live demo here) but not in C (See live demo here.) My compiler ( gcc 4.8.1 ) gives me following error when I compile it as a C program.
[Error] wrong type argument to unary plus
What purpose the unary plus operator serves here? What it does exactly here? Why it is not allowed in C?