|
-
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, 07:32 PM
-
By Seth Grossman [MSFT] in forum .NET
Replies: 1
Last Post: 02-15-2002, 12: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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks