Below is my code saved as .cpp file and .c file
in .c it compiled fine, but threw the following error in .cpp
test.cpp:6: error: initializer-string for array of chars is too long test.cpp:6: error: initializer-string for array of chars is too long
#include< stdio.h> int main() { char str[2][2]= { "12", "12"}; int i; for(i=0; i<2; i++) printf("%d %s\n", i, str[i]); return 0; }
Is there any compiler directive or anything so that the C ++ compiler perceives this as the C code itself.
I tried extern "C", which did not help.
source share