-
C++ and Visual Studio 2008 Passing 2 Dimensional Array
I am not new to programming but I am new to C++. I have followed the directions of other sites of how to pass a two-dimensional array to a function. I am getting a confusing error. Please note that I have been working on this issue for two evenings. I tried to solve the problem myself before posting. I am also aware of the syntax of passing an array with the width defined. I am wanting to write a general use function and I don't want to be locked into any specific size.
Thank you in advance.
Here is my code:
#include <iostream>
using namespace std;
void initialize2DCharArray(char** array, int height, int width, char initChar);
void initialize2DCharArray(char** array, int height, int width, char initChar)
{
for(int colCount=0;colCount < height; colCount++)
{
for(int rowCount=0;rowCount < width; rowCount++)
{
array[rowCount][colCount] = initChar;
}
}
}
void main()
{
char c[3][3];
initialize2DCharArray(c, 3, 3, 'A');
}
Here is the error:
error C2664: 'initialize2DCharArray' : cannot convert parameter 1 from 'char [3][3]' to 'char **'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Similar Threads
-
By jnesbett in forum .NET
Replies: 1
Last Post: 03-30-2009, 03:36 PM
-
By Seth Grossman [MSFT] in forum vb.announcements
Replies: 1
Last Post: 03-13-2002, 08:32 PM
-
By Seth Grossman [MSFT] in forum .NET
Replies: 1
Last Post: 02-15-2002, 01:35 AM
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|