constans array of string?

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
fixit
New poster
Posts: 5
Joined: Tue Jun 06, 2006 7:39 pm

constans array of string?

Post by fixit »

How to make a array of string whith is constans ?
How to make it with #DEFINE ?
misof
A great helper
Posts: 430
Joined: Wed Jun 09, 2004 1:31 pm

Post by misof »

Code: Select all

#include <iostream>
#include <string>
using namespace std;

string myStrings[] = {"hello", "world", "funny", "isn't", "it"};

int main() {
  cout << myStrings[1] << endl; // prints "world"
}
I can't imagine a reason why one should use #define here.
Post Reply

Return to “C++”