I have a string array in my main function, and i want to be able to use that string in a function inside of a class, how can i do this without having to copy and paste the entire string over again inside of my class.
If anyone can help me this would be greatly appreciated.
Is it a) a string literal such as the one in the line below, printf("Hello, World!\n");
or b) a pointer to a C string you need to pass to a function?
For a), you can do this: #define STR_000 "your string here"
For b), you need to tell the function you want to pass it a C string: T f(/*anything else*/ char *str /*anything else*/){/*...*/}
no, it is a string like this:
string names[5] = { "bob", "bill", "betty", "joe", "susy" };
In the .cpp file i need to run a function in a .h file which uses the string from above, located in the .cpp file.
I'm sorry if this does not make too much sense.
Belkdaddy, you might want to take a look at some of the tutorials. Pointers are an invaluable part of C++, and it sounds like you're starting to come around to using them. Check them out and see what you can find.