Browse - Programming Tips - How can I efficiently loop thru a constant array of strings?

Date: 2014apr8
Language: C/C++
Platform: Windows

Q.  How can I efficiently loop thru a constant array of strings?

A.  Here is a nice way do do that:

const LPCSTR things[] = { "One", "Two", Three", NULL }; // NULL terminated for (const LPCSTR *p = things; *p; p++) { printf("thing=%s\n", *p); // Use star-p }
This only works when you can define your own NULL-terminated array.