Initialize the results array so all elements are NULL:

char* results[10] = { NULL };

In the posted code the elements are unitialized and will be holding random values.

Additionally, prevent going beyond the bounds of the results array:

while (i < 10 && result)
{
}
Answer from hmjd on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › c language › how-to-check-if-empty-array-in-c
How to Check if Empty Array in C? - GeeksforGeeks
July 23, 2025 - So, it can't use any of them to make the array have a particular size. As a result, the array hasn't got any space to contain elements, which is why the above output shows that the size of the array is 0 bytes. Method 2: As the size of the array is already 0 so no memory is allocated to it. So, it is also empty
🌐
Cprogramming
cboard.cprogramming.com › c-programming › 180644-check-if-array-empty.html
Check if array is empty?
Code: struct pqueue { struct entry entries[10]; }pqueue; How can i check if the entry array 'entries' is empty? int isEmpty(struct pqueue* p
🌐
Sololearn
sololearn.com › en › Discuss › 1857864 › how-to-check-for-an-empty-array
How to check for an empty array? | Sololearn: Learn to code for FREE!
✓to check whether an array is empty or not just iterate the elements of the array and compare them with null character '/0'. ✓you can also declare an empty array like this arr[]={}. Then use the sizeof function, if it returns 0 your array ...
🌐
YouTube
youtube.com › hey delphi
Array : How to check if empty array in C - YouTube
Array : How to check if empty array in CTo Access My Live Chat Page, On Google, Search for "hows tech developer connect"As promised, I'm going to share a hid...
Published   April 13, 2023
Views   142
🌐
Quora
quora.com › How-can-you-determine-if-an-array-is-empty-or-not-in-C-Is-there-an-issue-with-this-code
How to determine if an array is empty or not in C++? Is there an issue with this code - Quora
Answer (1 of 3): In general we have two array (variable) types: * Static * Dynamic Static is code like: [code]int Array[100]; [/code]In this case we have absolutely no idea is array empty or not. Not only array but also variable. For pointers NULL was introduced to signal “empty” or not set p...
Find elsewhere
🌐
Arduino Forum
forum.arduino.cc › projects › programming
How to check if array is empty? - Programming - Arduino Forum
December 14, 2023 - Hello guys, I can't understand how Arduino can't provide methods for easy use of arrays, like length of array or check if array is empty. Seems pretty basic to me. I have this: String getstrValue ( const String oldStr…
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 412900 › c-how-to-check-array-is-empty-or-not-occupy
c++ how to check array is empty or not occupy? [SOLVED] | DaniWeb
Now, when you want to see if you have a house there, the contents of that entry in the array will be 0 (null) if it hasn't been used yet. ... cool, i never think the ways you two mentioned above, but i think i will use a counter to make it simple, i also have one more question about dynamic array i am trying to make my array grow(2x of original and copy the old element to the new array) as it's full, and this is the way i tried to implement, but the compiler keep giving me segmentation fault.
🌐
Quora
quora.com › How-do-I-check-if-a-char-array-is-empty
How to check if a char array is empty - Quora
Answer (1 of 10): Alan gave good answer but let me extend a bit. What empty char array means? Let me use C++ array (vector) class to explain. [code]std::vector String; [/code]In C world this is something like: [code]char* pString = NULL; // non allocated, zero sized array pString = (c...
🌐
Cplusplus
cplusplus.com › forum › general › 49016
How to check if array is empty or not - C++ Forum
This is the sample of the code: #include <iostream> #include <string> #include <fstream> using namespace std; struct Students{ string name; string surname; double score[10]; }; void inputs(Students List[], int p); void printinf(Students List[], int s); int main(){ char reply; do{ Students List[4]; inputs(List, 4); printinf(List,4); cout<< endl << "Do you want to run the programm again? y/n" << endl; cin>> reply; }while (reply != 'n'); return 0; } void inputs(Students List[], int p){ ifstream fin; fin.open("HW2.in"); for (int i = 0; i < 4; i++){ fin>> List[i].name; fin>> List[i].surname; List[i].name = List[i].name + " " + List[i].surname; for (int a=0; a<10; a++){ fin>> List[i].score[a]; } //The problem is here. How to check if there are less than ten elements for input and assign remaining elements of the array to zero?
🌐
Quora
quora.com › How-do-I-check-if-array-is-empty-or-not
How to check if array is empty or not - Quora
Answer (1 of 19): Question: How do I check if array is empty or not? You fail to mention the language - In Java it’s simple: Assuming you have an array called arr, simply test arr.length for > 0. If true, it’s not empty. Also a little more complex - if you use the java.util.Arrays class and call...
🌐
Cplusplus
cplusplus.com › forum › general › 180085
Check if object array is empty - C++ Forum
This tidbit might help you, albeit it shows you an example of arrays of ints, so if you're doing an array of custom class objects, you'll have to do a little more footwork on that.
🌐
Cplusplus
cplusplus.com › forum › general › 263820
checking empty dynamic array - C++ Forum
• Using sentinel values • Keeping count For c-strings and arrays of pointers, a sentinel will work. For example: If that looks confusing, it is because it is pointer arithmetic. You could use a counter too: Keeping track of it yourself is so very easy. BTW, there is not typically any need to keep a pointer to a std::string.