What is the difference between single quoted and double quoted declaration of char array? Last Updated : 06 Jan, 2025 Comments Improve Suggest changes Like Article Like Report In C programming, the way we declare and initialize a char array can differ based on whether we want to use a sequence of characters and strings. They are basically same with difference only of a '\0' NULL character.Double quotes automatically include the null terminator, making the array a string literal that can be safely used with string functions. On the other hand, single quotes are used for declaring an array of individual characters, without any null terminator, making it more suitable for scenarios where you need to work directly with the characters and manage their memory manually.Single-quoted DeclarationWhen you use single quotes to define an array of characters, each element in the array is a single-character literal. It is essentially a sequence of individual characters that do not automatically add a null terminator ('\0'), unlike a string.Example: C #include <stdio.h> int main() { // No null terminator char arr[] = { 'g', 'e', 'e', 'k', 's' }; // Print individual characters manually for (int i = 0; i < 5; i++) { printf("%c", arr[i]); } printf("\n"); return 0; } Outputgeeks However, if you try to print it using %s in printf, it won't work as expected since thereâs no null terminator:printf("%s", arr); // Incorrect, will cause undefined behaviorDouble-quoted DeclarationWhen you use double quotes, the C compiler automatically creates a string literal, which is an array of characters that ends with a null terminator ('\0').Example: C #include <stdio.h> int main() { // Null terminator included automatically char arr[] = "geeks"; // Print using string format specifier // Correct, prints "geeks" printf("%s", arr); return 0; } OutputgeeksThis works because the string literal "geeks" automatically includes the null terminator ('\0'), allowing functions like printf to correctly identify the end of the string. Comment More infoAdvertise with us Next Article Initialization of Multidimensional Array in C K kartik Follow Improve Article Tags : C Language C Array and String Similar Reads C Arrays An array in C is a fixed-size collection of similar data items.Items are stored in contiguous memory locations. Can be used to store the collection of primitive data types such as int, char, float, etc., as well as derived and user-defined data types such as pointers, structures, etc.C// A simple C 7 min read Properties of Array in C The properties of the arrays vary in different programming languages. In this article, we will study the different properties of Array in the C programming language.1. Fixed Size of an ArrayIn C, the size of an array is fixed after its declaration. It should be known at the compile time and it canno 7 min read Length of Array in C The Length of an array in C refers to the maximum number of elements that an array can hold. It must be specified at the time of declaration. It is also known as the size of an array that is used to determine the memory required to store all of its elements.In C language, we don't have any pre-defin 3 min read Multidimensional Arrays in C - 2D and 3D Arrays A multi-dimensional array in C can be defined as an array that has more than one dimension. Having more than one dimension means that it can grow in multiple directions. Some popular multidimensional arrays include 2D arrays which grows in two dimensions, and 3D arrays which grows in three dimension 8 min read Initialization of Multidimensional Array in C In C, multidimensional arrays are the arrays that contain more than one dimensions. These arrays are useful when we need to store data in a table or matrix-like structure. In this article, we will learn the different methods to initialize a multidimensional array in C. The easiest method for initial 4 min read Jagged Array or Array of Arrays in C with Examples Prerequisite: Arrays in CJagged array is array of arrays such that member arrays can be of different sizes, i.e., we can create a 2-D array but with a variable number of columns in each row. These type of arrays are also known as Jagged arrays. Example:arr[][] = { {0, 1, 2}, {6, 4}, {1, 7, 6, 8, 9}, 3 min read Pass Array to Functions in C Passing an array to a function allows the function to directly access and modify the original array. In this article, we will learn how to pass arrays to functions in C.In C, arrays are always passed to function as pointers. They cannot be passed by value because of the array decay due to which, whe 3 min read How to pass a 2D array as a parameter in C? A 2D array is essentially an array of arrays, where each element of the main array holds another array. In this article, we will see how to pass a 2D array to a function.The simplest and most common method to pass 2D array to a function is by specifying the parameter as 2D array with row size and co 3 min read How to pass an array by value in C ? In C programming, arrays are always passed as pointers to the function. There are no direct ways to pass the array by value. However, there is trick that allows you to simulate the passing of array by value by enclosing it inside a structure and then passing that structure by value. This will also p 2 min read Variable Length Arrays (VLAs) in C In C, variable length arrays (VLAs) are also known as runtime-sized or variable-sized arrays. The size of such arrays is defined at run-time.Variably modified types include variable-length arrays and pointers to variable-length arrays. Variably changed types must be declared at either block scope or 2 min read Like