Sunday, July 12, 2009

Wat is the diff b/w const char* p and char const *p?

I have doubt in C programming language.

Wat is the diff b/w const char* p and char const *p?
There is no functional difference. Its all just preference. Some people like to designate that a pointer is being used beside the data type, and others prefer to signify a point beside the variable name. Placement of "const" shouldn't matter either.





Notice that there is no functional difference in the outputs:





#include %26lt;iostream%26gt;





using namespace std;





int main(){


char d='a';


const char* c=%26amp;d;


char const *b=%26amp;d;





cout%26lt;%26lt;c%26lt;%26lt;endl;


cout%26lt;%26lt;b%26lt;%26lt;endl;





//Require for Dev-C++


//system("pause");





return 0;


}


No comments:

Post a Comment