In addition to Will Dean's version, the following are common for whole buffer initialization:

Copychar s[10] = {'\0'};

or

Copychar s[10];
memset(s, '\0', sizeof(s));

or

Copychar s[10];
strncpy(s, "", sizeof(s));
Answer from Matt Joiner on Stack Overflow
🌐
Reddit
reddit.com › r/cs50 › [caesar]how to declare an empty string array in c?
r/cs50 on Reddit: [Caesar]How to declare an empty string array in C?
April 26, 2014 -

How do I initialize it to anything other than zero or NULL? I just want an empty string array, which I can use to store text with the help of a for loop. I dont want to assign it the function of GetString. If I declare the array in between an operation like.

string c_txt[i] = (p_txt[i] + key) % 26;

where c_txt is the array containing enciphered text, p_txt is array containing plain text, the console pops me an error saying "variable-sized object may not be initialized".

Also, string c_txt = NULL; desent work for obvious reasons. So how do I declare this string array?

P.S : I have a really bad feeling that this is a really dumb question and I`m making a fool of myself in front of the staff. What am I missing?

🌐
C For Dummies
c-for-dummies.com › blog
Null Versus Empty Strings | C For Dummies Blog
A null string has no values. It’s an empty char array, one that hasn’t been assigned any elements. The string exists in memory, so it’s not a NULL pointer.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-empty-a-char-array-in-c
How to Empty a Char Array in C? - GeeksforGeeks
July 23, 2025 - strcpy is the predefined function already existing in the string header file. strcpy function helps us to copy elements of one array into another. ... Here first is the element where we need to copy elements and second is the array from which we are copying the elements. ... // C Program empty char array // Using strcpy to clear // the string #include <stdio.h> int main() { // Creating char array char arr[5] = { 'a', 'b', 'c', 'd', 'e' }; printf("Before: "); for (int i = 0; arr[i] != '\0'; i++) printf("%c ", arr[i]); printf("\n"); // Copying elements of empty array in arr strcpy(arr, ""); printf("After: "); for (int i = 0; arr[i] != NULL; i++) printf("%c ", arr[i]); return 0; }
🌐
Northern Illinois University
faculty.cs.niu.edu › ~winans › CS501 › Notes › cstrings.html
C Strings
The individual characters that make up the string are stored in the elements of the array. The string is terminated by a null character. Array elements after the null character are not part of the string, and their contents are irrelevant. A "null string" or "empty string" is a string with ...
🌐
Cprogramming
cboard.cprogramming.com › cplusplus-programming › 12230-setting-empty-string.html
Setting an empty string
char string[50] = ""; // creates an array of 50 characters with the initial string of \0. You are right either way but it depends on what you want to do as to which one you should use. A truly "empty" string would be char *pString = NULL;
🌐
DEV Community
dev.to › biraj21 › empty-strings-and-zero-length-arrays-how-do-we-store-nothing-1jko
Empty Strings and Zero-length Arrays: How do We Store... Nothing? - DEV Community
June 25, 2024 - When you create an empty string in C, you are essentially allocating a string that points to a memory location that stores the null character. This is akin to reserving a seat at a table for a ghost.
🌐
Quora
quora.com › How-do-you-initialize-char*-to-an-empty-string-in-C
How to initialize char* to an empty string in C - Quora
Answer (1 of 8): An empty string in C - meaning one that would be a legal-formed string that would be regarded as a string of zero-length by the string.h string functions and other functions that operate on strings - is simply [code ]""[/code]. It is an array of [code ]char [/code]with a element,...
Find elsewhere
🌐
Quora
quora.com › How-do-you-create-an-empty-array-in-C
How to create an empty array in C - Quora
Answer (1 of 10): Empty Array in C : [code]#include #define size 100 void main() { char name[size] ; // Empty array declaration clrscr(); printf(“Enter your name : ”); gets(name); printf(“Welcome to the magical world of Programming %s”, name); getch(); } [/code]
🌐
Cplusplus
cplusplus.com › forum › beginner › 248142
Is there problem to declare an empty char array?
Somebody declares array as char c[1024];. But I found the compiler does not stop me and there's no error after I've declared the array with char c[] = "";. Is there actually any potential problems if I do it this way? ... This does not declare an empty array. It declares an array that is big enough to hold the empty string, which requires one character because strings need to end with a null character '\0'.
🌐
Unstop
unstop.com › home › blog › strings in c | initialization and string functions (+examples)
Strings In C | Initialization and String Functions (+Examples)
May 30, 2025 - In the programming language C, ... string by creating a new variable that is a character array with no specified length, then giving it no value except for two quotes side-by-side, symbolizing blank space....
🌐
Python Examples
pythonexamples.org › c › how-to-create-an-empty-string
How to Create an Empty String in C
#include <stdio.h> int main() { char emptyString[] = "\0"; printf("Empty string created: '%s'", emptyString); return 0; }
🌐
Edaboard
edaboard.com › digital design and embedded programming › pc programming and interfacing
make a string empty in C | Forum for Electronics
September 15, 2011 - You could use calloc() which clears the storage allocated with NULL (\0), however storing a NULL (\0) in the first element of a character array is just as effective. BigDog ... if I coded In this way while(some_cond) { string=(char *)malloc(20,1); while(cond) { string[index]=assigne_something; ++index; } } i replaced malloc with calloc now?