Programming Tips - C/C++: Declare and list a constant array of strings

Date: 2021feb17 Language: C/C++ Level: beginner Keywords: win32, iterate Q. C/C++: Declare and list a constant array of strings A. Declare the array as follows - make sure you put a NULL at the end
#include <stdio.h> const char *numbers[] = { "one", "two", "three", NULL }; for (const char **p = numbers; *p; p++) { printf("%s\n", *p); }
// Windows-style const LPCSTR numbers[] = { "one", "two", "three", NULL }; for (const LPCSTR *p = numbers; *p; p++) { printf("%s\n", *p); }