Declaring an Array of Strings

This is a really newbie question, but I can't figure out what is going wrong. I'm just trying to use a simple string array. I've boiled do the code to show where the error is happening:

#include "stdafx.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cmath>
using namespace std;

int main(array<System::String ^> ^args)
{
char *color[2] = {red, blue};
return 0;
}

When I compile, I'm getting a 2065 error: undeclared identifier on each of the members of the array (red and blue). What am I doing wrong?

Thanks!
You need to wrap red and blue in quotes:
char *color[2] = {"red", "blue"};

With the way you have it, the compiler is trying to find what red and blue are identified as.
Something like:
int red;
for example. The identifier (like color) hasn't been declared with a type (like char*).
Last edited on
aaaaagh! I knew I was missing something. Thanks for pointing that out!
closed account (S6k9GNh0)
Stuff like that should eventually catch you're eye immediately. It's something that comes with time. :P
Just wait until you have to find an error because of something like this:
1
2
3
4
5
int a = 10;
if (a = 5)
{
     //code
}


where = should be ==
xD
Last edited on
Topic archived. No new replies allowed.