I know C++ is completely different language than C. Yet C++ acts as a super set of C.
I don't know why this code compiles and runs with just a few warnings in C and throws errors like scalar object 'a' requires one element in initializer
Here it is:
#include<stdio.h>
int tabulate(char **head){
//Stuffs here
}
int main(){
char **a={"Abc","Def"};
tabulate(a);
return 0;
}
Are there any other difference which C++ brings for C codes regarding pointers and arrays ?
const char *.std::stringis a class in the C++ library. C++, like C, has string literal constants. Except that they're always aconst char *, and, as you know, you can't assign a pointer to aconstobject to a pointer to a non-constobject. Neither in C, nor C++.constmodifier in the function parameter and in thea's declaration fix this ?tabulatewill try to mutate the parameter you just const-qualified.