How to test is a string is initialized in c?

c, initialization, string

Solution

You can't.

Instead, initialize it with `NULL` and check whether it is `NULL`:

char *foo = NULL;
...
if(!foo) { /* shorter way of saying if(foo == NULL) */

Problem

Quick and easy C question: `char* foo` How can I test if `foo` hasn't still been assigned a value? Thanks.

Original source