|
-
July 28th, 2005, 11:37 PM
#1
Problem With Function Returning 2-Dim ******* Array
I made 2 functions one that returns 2-Dim Character Array and the other one returning 2-Dim ******* Array. In case of character array it works but in case of ******* array instead of displaying those numbers in Arrays its showing memory locations. Here is the code.
#include <iostream.h>
#include <conio.h>
char **edit(char **str); // Prototype for 2-Dim Character Array
int **Dim (int **num); // Prototype for 2-Dim ******* Array
void main()
{
char **str;
int **num;
str = new char* [255];
num = new int* [255];
edit(str); // Call for 2-Dim Character Array
Dim (num); // Call for 2-Dim ******* Array
for(int j=0;j<3;j++)
{
cout<<str[j]<<endl;
cout<<num[j]<<endl; // The Problem lies over here, Address is getting printed
}
delete str;
delete num;
}
char **edit(char **str)
{
char *pNames[] = {"Maverick","Marlin","Slider"};
for(int j=0;j<3;j++)
{
str[j] = new char[255];
str[j] = pNames[j];
}
return str;
}
int **Dim (int **num)
{
int pNums[][3] = {3,4,5,6,5,4,6,1,9,5,5,1,0,0,6};
for (int i=0; i<3; i++)
{
num[i] = new int[20];
num[i] = pNums[i];
}
return num;
}
Can anyone help in sorting this?
Last edited by maverick786us; July 29th, 2005 at 01:04 AM.
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
|
Click Here to Expand Forum to Full Width
|