U++ framework
Do not panic. Ask here before giving up.

Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » How to use string array with functions?
How to use string array with functions? [message #9670] Thu, 24 May 2007 19:39 Go to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
I'm using a String array:

String data[4];

data[0] = "string_0";
data[1] = "string_0";
data[2] = "string_0";
data[3] = "string_0";
data[4] = "string_0";


Now i want to use these Strings in another function:

a_function(data[]);


But i got these error:

error: expected primary-expression before ']' token


What's the right way to do it?

Michael

[Updated on: Sun, 27 May 2007 15:09]

Report message to a moderator

Re: How to use string array with functions? [message #9671 is a reply to message #9670] Thu, 24 May 2007 19:44 Go to previous messageGo to next message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
Solved...

a_function(data);


This will pass the complete array to a_function.

Michael
Re: How to use string array with functions? [message #9715 is a reply to message #9670] Sun, 27 May 2007 15:03 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
michael wrote on Thu, 24 May 2007 19:39

I'm using a String array:

String data[4];

data[0] = "string_0";
data[1] = "string_0";
data[2] = "string_0";
data[3] = "string_0";
data[4] = "string_0";




use only data[0] to data[3] !!!! you created an array with 4 elements not up to 4 !

Bas
Re: How to use string array with functions? [message #9716 is a reply to message #9670] Sun, 27 May 2007 15:04 Go to previous message
michael is currently offline  michael
Messages: 153
Registered: May 2007
Location: Germany
Experienced Member
You're right. Thanks. It was only an example.

Michael
Previous Topic: How to access other classes variables?
Next Topic: Trouble with pointers.
Goto Forum:
  


Current Time: Mon May 11 06:47:12 GMT+2 2026

Total time taken to generate the page: 0.00531 seconds