Reputation: 1313
I've been doing PHP and stuff for the last year; I just got into a bit of C and C++.
In the book I'm just reading, all the strings are actually in the code (I realize this is just for example, but just curious).
My interest is — is there a common way for programmers to store strings and display them? Does .NET have some predefined way of doing this — like Android does in strings file?
(In PHP, I keep them in all CSV files completely separate from code.)
Upvotes: 0
Views: 153
Reputation: 754570
For C and C++, you can consider using the GNU gettext
system. POSIX has a related system. Basically, they provide files stored in a known location that contain localized versions of the strings in the program. At runtime, the code collects the correct version of the message from the appropriate file for use by the program.
These are loosely related to the resource files found on Windows systems.
Upvotes: 0
Reputation: 486
if you asking about how to store strings in code: use preprocessor e.g.
string_literals.h
#define PATH_TO_FILE "/home/usr/filename"
/* and so on...*/
*.cpp file
#include "string_literals.h"
const char* path = PATH_TO_FILE;
Upvotes: 1