hi all,
I am new to c++. I want to return array. I found that I have to use pointers but doesnt have idea.
here is my code
// test2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
const int rows=13;
const int coloums=6;
char *begingStatus();
void print(char val[rows][coloums]);
int _tmain(int argc, _TCHAR* argv[])
{
cout <<"hi ";
char *ptr = new char[rows][coloums];
ptr=begingStatus();
// int nptrewarray[5]=ptr;
print(ptr);
cin.get();
return 0;
}
void print(char val[rows][coloums])
{
for(int i=1; i<14;i++)
{
for(int j=1;j<7; j++)
{
cout <<val[i][j];
cout << '\n';
}
}
}
char *begingStatus()
{
char *seats= new char[rows][coloums];
for(int i=1; i<rows;i++)
{
for(int j=1;j<coloums; j++)
{
seats[i][j]='*';
}
}
return seats;
}
plz check my code and let me know how to correct this
thanks in advance,
menuaka