char*
is a mutable pointer to a mutable character/string.
const char*
is a mutable pointer to an immutable character/string. You cannot change the contents of the location(s) this pointer points to. Also, compilers are required to give error messages when you try to do so. For the same reason, conversion from const char *
to char*
is deprecated.
char* const
is an immutable pointer (it cannot point to any other location) but the contents of location at which it points are mutable.
const char* const
is an immutable pointer to an immutable character/string.
Related Posts:
- Constant pointer vs Pointer to constant
- Pointer Arithmetic
- char *array and char array[]
- C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
- What is the difference between char s[] and char *s?
- What is the difference between const int*, const int * const, and int const *?
- What is the difference between const int*, const int * const, and int const *?
- #31 expression must have integral type
- How do you pass a function as a parameter in C?
- Invalid pointer error on invoking free() after malloc in C
- expression must have integral type
- What’s wrong with my code? What is argv[1]?
- Valgrind: Invalid read of size 1
- Reversing a string in C
- Warning: return from incompatible pointer type in C
- strcmp giving segmentation fault
- Why am I getting this error: “data definition has no type or storage class”?
- warning: passing argument ’from incompatible pointer type [enabled by default]’
- char pointers: invalid conversion from ‘char*’ to ‘char’?
- What is the difference between char array and char pointer in C?
- typedef struct pointer definition
- Dereference void pointer
- The difference between char * and char[] [duplicate]
- lvalue required as increment operand
- How big can a 64 bit unsigned integer be?
- What is *(uint32_t*)?
- Why should we typedef a struct so often in C?
- What is a string of hexadecimal digits?
- What is the difference between ++i and i++?
- Stack smashing detected
- Stack smashing detected
- How do I determine the size of my array in C?
- Why am I getting “void value not ignored as it ought to be”?
- Openssl : error “self signed certificate in certificate chain”
- What is the difference between C and embedded C?
- How do I create an array of strings in C?
- Difference between malloc and calloc?
- segmentation fault : 11
- What are .a and .so files?
- So what does “return 0” actually mean?
- warning: assignment makes integer from pointer without a cast
- Why use bzero over memset?
- how to use uint64_t in C [duplicate]
- How do I solve the following errors: “Undefined reference to WinMain”, “[Error] Id returned 1 exit status”?
- Warning comparison between pointer and integer
- How do I properly compare strings in C?
- Connect: Socket operation on non-socket
- How to correctly use the extern keyword in C
- How do we check if a pointer is NULL pointer?
- how to use wait in C
- what is the meaning of == sign?
- How do I calculate MB/s & MiB/s?
- ARM Assembler – How do I use CMP, BLT and BGT?
- Invalid read of size 8 – Valgrind + C
- warning: incompatible implicit declaration of built-in function ‘xyz’
- strcpy vs strdup
- Warning comparison between pointer and integer in C language
- error: expected declaration or statement at end of input in c
- Why does the arrow (->) operator in C exist?
- Why do I get clang: error: linker command failed with exit code 1?
- Difference between scanf() and fgets()
- Return char[]/string from a function [duplicate]
- How to convert integer to char in C?
- Is there a printf converter to print in binary format?
- Program received signal SIGPIPE, Broken pipe
- How to read from stdin with fgets()?
- Why am I getting “array initializer must be an initializer list or string literal”?
- what is the unsigned datatype?
- Incompatible implicit declaration of built-in function ‘malloc’
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- expression must have integral type
- Need more information about Aborted (core dumped)
- Does C have a “foreach” loop construct?
- What is a bus error? Is it different from a segmentation fault?
- What is the cause of flexible array member not at end of struct error?
- How can I get argv[] as int?
- Why I do get “Cannot find bound of current function” when I overwrite the ret address of a vulnerable program?
- Warning: assignment from incompatible pointer type
- valgrind – Address —- is 0 bytes after a block of size 8 alloc’d
- How to printf a memory address in C
- What is the use of intptr_t?
- Writing binary number system in C code
- Returning an array using C
- How does one represent the empty char?
- Removing trailing newline character from fgets() input
- “Multiple definition”, “first defined here” errors
- Get size of pointer in C
- how use EOF stdin in C
- Execution of printf() and Segmentation Fault
- How does the strtok function in C work? [duplicate]
- Allocating char array using malloc
- Implementation of strtok() function
- Reaching EOF with fgets
- Difference between char* and char** (in C)
- How to clear input buffer in C?
- Difference between the int * i and int** i
- Pointer to 2D arrays in C
- Pointer to a string in C?
- Initialization makes pointer from integer without a cast – C
- error: `itoa` was not declared in this scope