answersLogoWhite

0


Best Answer

const char *p means the char value pointed by 'p' is constant we can't change anyway but the address(location) of 'p' can change.

char const *p means the char value pointed by 'p' can change but the location of p can't be change it is constant.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between const char and char const?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the full form of printf or scanf?

int printf (const char *fmt, ...)orint scanf (const char *fmt, ...)


What is the prototype of printf function?

in stdio.h:extern int printf (const char *fmt, ...);


How do you beat first gym diamond?

// Tic-Tac-Toe // Plays the game of tic-tac-toe against a human opponent #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; // global constants const char X = 'X'; const char O = 'O'; const char EMPTY = ' '; const char TIE = 'T'; const char NO_ONE = 'N'; // function prototypes void instructions(); char askYesNo(string question); int askNumber(string question, int high, int low = 0); char humanPiece(); char opponent (char piece); void displayBoard(const vector<char>& board); char winner(const vector<char>& board); bool isLegal(const vector<char>& board, int move); int humanMove (const vector<char>& board, char human); int computerMove(vector<char> board, char computer); void announceWinner (char winner, char computer, char human); // main function int main() { int move; const int NUM_SQUARES = 9; vector<char> board(NUM_SQUARES, EMPTY); instructions(); char human = humanPiece(); char computer = opponent(human); char turn = X; displayBoard(board); while (winner(board) human) { cout << winner << "'s won!\n"; cout << "No, no! It cannot be! Somehow you tricked me, human.\n"; cout << "But never again! I, the computer, so swear it!\n"; } else { cout << "It's a tie.\n"; cout << "You were most lucky, human, and somehow managed to tie me.\n"; cout << "Celebrate. . . for this is the best you will ever achieve.\n"; } }


In function definition void fun char Petr what needs to be modified to prevent the object pointed by Petr from being altered?

You need to modify the argument type from char to const char: void fun (const char * Petr) {/*...*/}


Write a function for concatnating the string s1 s2 and storing the result in string s3?

char *strmerge (char *s3, const char *s1, const char *s2) { strcpy (s3, s1); strcat (s3, s2); return s3; }


What is tic tac toe 2.0?

// Tic-Tac-Toe // Plays the game of tic-tac-toe against a human opponent #include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; // global constants const char X = 'X'; const char O = 'O'; const char EMPTY = ' '; const char TIE = 'T'; const char NO_ONE = 'N'; void instructions(); char askYesNo(string question); int askNumber(string question, int high, int low = 0); char humanPiece(); char opponent(char piece); void displayBoard(const vector<char>* const pBoard); char winner(const vector<char>* const pBoard); bool isLegal(const vector<char>* const pBoard, int move); int humanMove(const vector<char>* const pBoard, char human); int computerMove(vector<char> board, char computer); void announceWinner(char winner, char computer, char human); // main function int main() { int move; const int NUM_SQUARES = 9; vector <char> board(NUM_SQUARES, EMPTY); instructions(); char human = humanPiece(); char computer = opponent(human); char turn = X; displayBoard(&board); while (winner(&board) human; board [move] = EMPTY; } if (!found) { ++move; } } } if (!found) { move = 0; unsigned int i=0; const int BEST_MOVES[] = {4, 0, 2, 6, 8, 1, 3, 5, 7}; while (!found && i< board.size()) { move = BEST_MOVES[i]; if (isLegal(move, &board)) { found = true; } ++i; } } cout << " I Shall take square number" << move << endl; return move; } void announceWinner(char winner, char computer, char human) { if (winner == computer) { cout << winner << "'s won!\n"; cout << "As I predicted, human, I am triumphant once more - proof\n"; cout << "that computers are superior to humans in all regards.\n"; } else if (winner == human) { cout << winner << "'s won!\n"; cout << "No, no! It cannot be! Somehow you tricked me, human.\n"; cout << "But never again! I, the computer, so swear it!\n"; } else { cout << "It's a tie.\n"; cout << "You were most lucky, human, and somehow managed to tie me.\n"; cout << "Celebrate... for this is the best you will ever achieve.\n"; } }


What is the difference between inline and const?

Everything. "inline" refers to functions, "const" refers to variables.


C programming copying of two strings?

/* this is the same functionality as strcpy() */ /* note that this, like strcpy, is not buffer overrun safe */ char *StringCopy (char *destination, const char *source) { const char *temp = destination; while ((*destination++ = *source++) != '\0'); return temp; }


What is the difference between tar and char?

The spelling!


Program to copy one string to another?

As usual, you should check official documentation before you ask a question like this. string.h // Copies num characters from source into destination. char* strncpy (char* destination, const char* source, size_t num); // Copies characters from source into destination. char* strcpy (char* destination, const char* source);


How do you write a user define function of strcpy?

char* u_strcpy (char* dest, const char* src) { char* temp = dest; while ((*dest++ = *src++) != '\0'); return temp; }


Pointer version of string function strcpy?

char* strcpy(const char* src, char* dst) { char* tmp = dst; while ((*dst++ = *src++) != '\0'); return tmp; }