const char *

char * const

What is the differnce between the above two?

Answer Posted / p s

const char *s; is a non-const pointer to const char
char * const s; is a const pointer to non-const char

Once u assign a value to the const poinet it cannot be
reassigned another value till u use casting techniques..

char a = 'A';
char b = 'B';
char *const c = &a;
c = &b; //flags an errror

const char *s = &a;
s = &b //works

Is This Answer Correct ?    19 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A prime number is a number which is divisible only by itself and 1. Examples of the first few primes are 2, 3, 5, 7, 11. Consider writing a program which can generate prime numbers for you. Your program should read in and set a maximum prime to generate and a minimum number to start with when looking for primes. This program should be able to perform the following tasks: 1. Read the maximum number from user (keyboard input) to look for primes. The program should not return any primes greater than this number. 2. Read the minimum number from user (keyboard input) to look for primes. The program should not return any primes less than this number. 3. Generate and print out every prime number between the maximum prime and minimum number specified by the user.

1736


Explain dangling pointer.

674


Is there a c++ certification?

595


What can c++ be used for?

578


Why should you learn c++?

572






What is a dll entry point?

553


Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()

996


Can you pass an array to a function in c++?

530


By using c++ with an example describe linked list?

592


What is c++ map?

557


How do you print a string on the printer?

569


What is the difference between #import and #include?

543


Why can templates only be implemented in the header file?

648


How a modifier is similar to mutator?

622


What does it mean to declare a destructor as static?

617