Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multidimensional arrays in functions

Status
Not open for further replies.

Seafury888

Programmer
Jun 3, 2003
11
CA
I'm wondering how to pass an array of strings to a function.
Ie:
Code:
//variable declaration
char roman1[50][20];

//function prototype
void Thousands(int[], int[], int, char[]);

//function call
Thousands(num1, num3, j, roman1[20]);

//function header
void Thousands(int num1[], int num3[], int j, char roman1[])

//this line is in the function and gives me the error, cannot convert 'int' to 'char *'
strcpy(roman1[j],"M");

Any help with this issue would be awesome.
Thanks
Seafury
 
Put "M" in single quotes 'M'. Post again if that doesn't fix it.

Chris
 
Nope didn't fix it, I think I have to pass the array as a reference....trying to figure out the syntax.

Seafury
 
To pass pointers to a function do like this:

char String[BigOne];

void Clear_String(char * AnyString, int TheSize)
{
while(TheSize--) *(AnyString++) = 0;
}

void main(void)
{
Clear_String(&String, sizeof(String)); // Clear the string
}


Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top