If ip_string is a null-terminated string, then you only need to initialize the first character of the string to null. Nothing is gained by filling the entire array with nulls.
On the other hand, you might like to do something like this:
- char ip_string[] = "XXX.XXX.XXX.XXX";
-
...
-
ip_string[0] = '\0'; // Set ip_string to "".
Notice that the array size is implied by the length of the initializer string. The advantage here is that it is much easier to see at a glance that the array size is large enough to hold an IP address string.
By the way ... There is no easy way to say this, you are confusing NULL with null. (Sounds like
Who's on First.)
NULL [
all uppercase] is a macro that is defined by several of the standard header files (stdio.h, stdlib.h, etc). The value of NULL is guaranteed to be 0. This macro is used wherever you want to indicate a pointer that doesn't point to anything (a NULL pointer).
Null [
mixed-case or all lowercase] is the name of the character used to terminate strings. The value of null is guaranteed to be '\0'. The compiler does not predefine a macro or symbol named "null". The term 'null' is similar to terms like 'function' or 'operand' in that none of these terms have any special meaning to the compiler, but programmers use them to describe what they are doing.