c++ - How do I check if a const char*'s value is defined? -
my application reads settings conf file first, , options can overwritten cli arguments. after loads settings conf, need check if require values set i'm stuck @ making check variables.
sample code:
#include <stdio.h> int main() { const char* test; if (test != null) std::cout << test << "\n"; else std::cout << "no value set\n"; return 0; } what did wrong?
you didn't initialize test. if want null initially, have set it:
const char* test = null;
Comments
Post a Comment