The same notation is used for pointing at a single character or the first character of a null-terminated string:

char c = 'Z';
char a[] = "Hello world";

char *ptr1 = &c;
char *ptr2 = a;      // Points to the 'H' of "Hello world"
char *ptr3 = &a[0];  // Also points to the 'H' of "Hello world"
char *ptr4 = &a[6];  // Points to the 'w' of "world"
char *ptr5 = a + 6;  // Also points to the 'w' of "world"

The values in ptr2 and ptr3 are the same; so are the values in ptr4 and ptr5. If you're going to treat some data as a string, it is important to make sure it is null terminated, and that you know how much space there is for you to use. Many problems are caused by not understanding what space is available and not knowing whether the string was properly null terminated.

Note that all the pointers above can be dereferenced as if they were an array:

 *ptr1    == 'Z'
  ptr1[0] == 'Z'

 *ptr2    == 'H'
  ptr2[0] == 'H'
  ptr2[4] == 'o'

 *ptr4    == 'w'
  ptr4[0] == 'w'
  ptr4[4] == 'd'

  ptr5[0] ==   ptr3[6]
*(ptr5+0) == *(ptr3+6)

Late addition to question

What does char (*ptr)[N]; represent?

This is a more complex beastie altogether. It is a pointer to an array of N characters. The type is quite different; the way it is used is quite different; the size of the object pointed to is quite different.

char (*ptr)[12] = &a;

(*ptr)[0] == 'H'
(*ptr)[6] == 'w'

*(*ptr + 6) == 'w'

Note that ptr + 1 points to undefined territory, but points 'one array of 12 bytes' beyond the start of a. Given a slightly different scenario:

char b[3][12] = { "Hello world", "Farewell", "Au revoir" };

char (*pb)[12] = &b[0];

Now:

(*(pb+0))[0] == 'H'
(*(pb+1))[0] == 'F'
(*(pb+2))[5] == 'v'

You probably won't come across pointers to arrays except by accident for quite some time; I've used them a few times in the last 25 years, but so few that I can count the occasions on the fingers of one hand (and several of those have been answering questions on Stack Overflow). Beyond knowing that they exist, that they are the result of taking the address of an array, and that you probably didn't want it, you don't really need to know more about pointers to arrays.

Answer from Jonathan Leffler on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ help me with pointers and strings!
r/C_Programming on Reddit: HELP ME WITH POINTERS AND STRINGS!
June 21, 2024 -

Hi, i don't really understand something about strings and pointers So basically a string is an character array ( correct me if im wrong) and we all know that the name of an array is a constant pointer which means we cannot increment or decrement it Although that i found sometimes they do increment the pointer For exemple

Char*S="hello"; While((*S)!='/0') S++ Please someone explain to me the difference between a string and a character array along with pointers!!

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ array-of-pointers-to-strings-in-c
Array of Pointers to Strings in C - GeeksforGeeks
November 14, 2025 - In C, arrays are data structures that store data in contiguous memory locations. Pointers are variables that store the address of data variables. We can use an array of pointers to store the addresses of multiple elements.
Discussions

Pointer to a string in C? - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... I know that ptrChar is a pointer to char. What's the command for a pointer to string? More on stackoverflow.com
๐ŸŒ stackoverflow.com
String class and pointers - C++ Forum
Can someone show me, or give me a link on how to use pointers with the string class? I've got a small program that i made a while back that uses c-strings and I want to 'upgrade' it to use the string class instead but i'm having trouble passing strings to a function. More on cplusplus.com
๐ŸŒ cplusplus.com
HELP ME WITH POINTERS AND STRINGS!
In your example, "hello" is an array of six characters having the values 'h', 'e', 'l', 'l', 'o', '\0'. It's allocated in an unspecified location and while the compiler lets you cheat and lose the constness, you shouldn't attempt to change this. You then try to initialize S with it. S is a pointer to a (single) char. C gives you a free conversion from array of x to pointer to the x and uses the address of the first element. IN this case s is pointing at the h. Your while loop checks where s points (*s) to see if it is not equal to '\0' (I assume you really wanted char and while not Char and While and \0 not /0). If it is not equal, then the body of the while runs which increments S. The loop ends with S is pointing at the \0. More on reddit.com
๐ŸŒ r/C_Programming
12
0
June 21, 2024
Running in circles trying to understand strings and pointers
Instead of circles, try thinking more linearly. My 2 cents ๐Ÿ‘Œ More on reddit.com
๐ŸŒ r/C_Programming
8
0
April 20, 2022
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ string pointer in c
String Pointer in C - Scaler Topics
January 16, 2024 - The tutorial delves into the concept of string pointers, explaining how pointers aid in accessing string indices, providing insights into the efficient manipulation of string data. Individual characters in C are enclosed within a single quote for example, 'a', 'b', 'c'. As explained in the previous section, a string is a collection of characters. To store a string in C, we can create an array and store them in these arrays.
๐ŸŒ
Cuny
cs.hunter.cuny.edu โ€บ ~sweiss โ€บ resources โ€บ cstrings.pdf pdf
Software Design Lecture Notes C Strings and Pointers Prof. Stewart Weiss
We say that intptr is a pointer to int and that doubleptr is a pointer to double. Although we could ยท also say that charptr is a pointer to char, we say instead that charptr is a string.
Top answer
1 of 3
34

The same notation is used for pointing at a single character or the first character of a null-terminated string:

char c = 'Z';
char a[] = "Hello world";

char *ptr1 = &c;
char *ptr2 = a;      // Points to the 'H' of "Hello world"
char *ptr3 = &a[0];  // Also points to the 'H' of "Hello world"
char *ptr4 = &a[6];  // Points to the 'w' of "world"
char *ptr5 = a + 6;  // Also points to the 'w' of "world"

The values in ptr2 and ptr3 are the same; so are the values in ptr4 and ptr5. If you're going to treat some data as a string, it is important to make sure it is null terminated, and that you know how much space there is for you to use. Many problems are caused by not understanding what space is available and not knowing whether the string was properly null terminated.

Note that all the pointers above can be dereferenced as if they were an array:

 *ptr1    == 'Z'
  ptr1[0] == 'Z'

 *ptr2    == 'H'
  ptr2[0] == 'H'
  ptr2[4] == 'o'

 *ptr4    == 'w'
  ptr4[0] == 'w'
  ptr4[4] == 'd'

  ptr5[0] ==   ptr3[6]
*(ptr5+0) == *(ptr3+6)

Late addition to question

What does char (*ptr)[N]; represent?

This is a more complex beastie altogether. It is a pointer to an array of N characters. The type is quite different; the way it is used is quite different; the size of the object pointed to is quite different.

char (*ptr)[12] = &a;

(*ptr)[0] == 'H'
(*ptr)[6] == 'w'

*(*ptr + 6) == 'w'

Note that ptr + 1 points to undefined territory, but points 'one array of 12 bytes' beyond the start of a. Given a slightly different scenario:

char b[3][12] = { "Hello world", "Farewell", "Au revoir" };

char (*pb)[12] = &b[0];

Now:

(*(pb+0))[0] == 'H'
(*(pb+1))[0] == 'F'
(*(pb+2))[5] == 'v'

You probably won't come across pointers to arrays except by accident for quite some time; I've used them a few times in the last 25 years, but so few that I can count the occasions on the fingers of one hand (and several of those have been answering questions on Stack Overflow). Beyond knowing that they exist, that they are the result of taking the address of an array, and that you probably didn't want it, you don't really need to know more about pointers to arrays.

2 of 3
11

The very same. A C string is nothing but an array of characters, so a pointer to a string is a pointer to an array of characters. And a pointer to an array is the very same as a pointer to its first element.

๐ŸŒ
Carnegie Mellon University
cs.cmu.edu โ€บ ~ab โ€บ 15-123S09 โ€บ lectures โ€บ Lecture 04 - Pointers and Strings.pdf pdf
Lecture 4 Strings and Pointers
out of fixed and variable lengths, integers, floating ยท points numbers etc. For example you can think of a CMU ... Suppose we need to swap two strings. A simple swapstring ... C strings are supported by the string.h library. The ... NULL. Each call returns a pointer to the next
๐ŸŒ
Microchip Developer Help
developerhelp.microchip.com โ€บ xwiki โ€บ bin โ€บ view โ€บ software-tools โ€บ compilers โ€บ c-programming โ€บ data-pointers โ€บ pointers-strings
C Programming Pointers and Strings - Developer Help
August 26, 2025 - If you want to test a string for equivalence, the natural thing to do is: if (str == "Microchip"). However, a string pointer in C is not even close to a string data type. If we do a comparison like if (str == "Microchip"), the compiler will compare the address contained in the pointer str with the address of the string literal "Microchip" (the literal is stored in program memory and accessed via the PSV on the 16-bit devices).
Find elsewhere
๐ŸŒ
DEV Community
dev.to โ€บ missmati โ€บ pointers-arrays-strings-in-c-52h3
Pointers , Arrays & Strings in C - DEV Community
October 11, 2022 - ** To access the string array, we need to create a pointer to the array and initialize the pointer with the array.
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2019 โ€บ 02 โ€บ c-program-to-print-string-using-pointer
C Program to Print String using Pointer
February 24, 2019 - We have assigned the array base address (address of the first element of the array) to the pointer and then we have displayed the every element of the char array by incrementing the pointer in the while loop. #include <stdio.h> int main() { char str[100]; char *p; printf("Enter any string: "); fgets(str, 100, stdin); /* Assigning the base address str[0] to pointer * p.
๐ŸŒ
Villanova
csc.villanova.edu โ€บ ~mdamian โ€บ Past โ€บ csc8400fa15 โ€บ notes โ€บ 05_Pointers.pdf pdf
1 CSC 8400: Computer Systems Pointers, Arrays and Strings in C Overview
Arrays vs. Pointers ... All these declarations are equivalent! Try them out. ... C vs. Java Strings ... Do not use strlen in your code.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointers_arrays.php
C Pointers and Arrays
Especially with simple arrays like in the examples above. However, for large arrays, it can be much more efficient to access and manipulate arrays with pointers. It is also considered faster and easier to access two-dimensional arrays with pointers. And since strings are actually arrays, you ...
๐ŸŒ
Medium
medium.com โ€บ @theodoretsori โ€บ c-pointers-arrays-and-strings-a-comprehensive-guide-73d046372a4e
C Pointers, Arrays, and Strings: A Comprehensive Guide | by Theodore Tsori | Medium
December 27, 2022 - For example, the following code ... pointers, arrays, and strings are important data types in C that enable programmers to manipulate memory directly and work with various types of data....
๐ŸŒ
Learn Loner
learnloner.com โ€บ home โ€บ uncategorised โ€บ pointers and strings in c
Pointers and Strings in C
February 5, 2024 - After initialization, the pointer ... is a sequence of characters stored in an array terminated by the null character '\0'. Strings can be represented using character arrays or pointers....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ c language โ€บ storage-for-strings-in-c
Storage for Strings in C - GeeksforGeeks
July 23, 2025 - In the above line "GfG" is stored in a shared read-only location, but pointer str is stored in read-write memory. You can change str to point something else but cannot change value at present str. So this kind of string should only be used when we don't want to modify the string at a later stage in the program. ... Strings are stored like other dynamically allocated things in C and can be shared among functions.
๐ŸŒ
Codedamn
codedamn.com โ€บ news โ€บ c programming
Accessing String Using Pointers in C
March 10, 2024 - Through pointers, C programmers can directly access and modify strings character by character, offering a granular level of control. Individual characters in a string can be accessed using pointer arithmetic.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ c-program-demonstrating-the-concepts-of-strings-using-pointers
C program demonstrating the concepts of strings using Pointers
a[2] is a pointer to the base add of string "three". Following is a C program demonstrating the concepts of strings โˆ’ ... #include<stdio.h> #include<string.h> void main(){ //Declaring string and pointers// char *s="Meghana"; //Printing required O/p// printf("%s ",s);//Meghana// printf("%c ",s);//If you take %c, we should have * for string.
๐ŸŒ
W3Schools
w3schools.com โ€บ c โ€บ c_pointers.php
C Pointers
Create a pointer variable with the name ptr, that points to an int variable (myAge). Note that the type of the pointer has to match the type of the variable you're working with (int in our example).
๐ŸŒ
OverIQ
overiq.com โ€บ c-programming-101 โ€บ array-of-pointers-to-strings-in-c โ€บ index.html
Array of Pointers to Strings in C - C Programming Tutorial - OverIQ.com
Here sports is an array of pointers to strings. If initialization of an array is done at the time of declaration then we can omit the size of an array. So the above statement can also be written as: It is important to note that each element of the sports array is a string literal and since a string literal points to the base address of the first character, the base type of each element of the sports array is a pointer to char or (char*).
๐ŸŒ
Cplusplus
cplusplus.com โ€บ forum โ€บ beginner โ€บ 10847
String class and pointers - C++ Forum
Note that a string* pointer points to a string object. It does not point to the individual character data within a string. ... Ok, yeah thats cleared up some blind spots for me. One question relating c-strings though. As i said before the original program i created used c-strings and i passed ...
๐ŸŒ
Dyclassroom
dyclassroom.com โ€บ c โ€บ c-pointers-and-strings
C - Pointers and Strings - C Programming - dyclassroom | Have fun learning :-)
In the following code we are assigning the address of the string str to the pointer ptr. ... We can represent the character pointer variable ptr as follows. The pointer variable ptr is allocated memory address 8000 and it holds the address of the string variable str i.e., 1000.