My problem is that I have to pass two dimensional array into member function and fill it. I've tried solve it on few ways but only success is without class in main fuction create object and fill array in that object, but that isn't what I need. I've read in book that is posible solve with pointers, but they haven't provided explanation only siad that is a beat hard. Recantly I heard that is posible solve in class much easier, but I don't know how? :sad:
I need any solution that can work.
Thank you!

// new3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class twodymArray
{public:
	int Row;
	int Column;
public:
	char **pArray;
	twodymArray(); // default constructor
	string primer;
	twodymArray(string Cprimer,int Cletters);  //constructor
	twodymArray(twodymArray &);                //copy constructor
	void setRow (){Row = primer.size();};     //inline member finction
	void setArray(int Row, int Column, string primer, char **pArray);
};
twodymArray::twodymArray()
{
pArray = NULL;
}

twodymArray::twodymArray(string Cprimer,int Cletters)
{
primer = Cprimer;
Column = Cletters;
setRow();
void setArray(int Row, int Column, string primer, char **pArray);

pArray = new char*[Row] ;
	for(int i=0; i<Row; ++i) {
		pArray[i] = new char[Column+1] ;
		pArray[i][Column-1] = NULL ;
	}cout<<"Column = "<<Column<<endl;
}

twodymArray::twodymArray(twodymArray &objtwodymArray)  //copy constructor
{
pArray = new char*[Row];
	for (int i = 0; i < Row; i++) {
		
		
		pArray[i] = new char[Column + 1];
		pArray[i][0] = Column;
		for (int j = 1; j <= Column; j++)
			pArray[i][j] = i + 1 + j / 100.;
	}
}


void setArray(int Row, int Column,string primer,char **pArray)
{string s2;
for(int i=0; i<(Row-(Column-1)); i++)			//formula (row-(letters-1)) je nuzna da ne izadje izvan
{												//polja a daje broj koliko ce se "usporedjica" napraviti
		for (int j=0; j<Column; j++)  //for petlja je skraceni oblik pisanja [i+1] + [i+2] +....
		{s2 = s2 + primer[i+j];}	  //jer tako unosom varijable letters mogu dobit potreban broj ponavljanja
		
			for (int l=0; l<Column; l++)  //upisuje stringove s2 u "array". "l" petlju svaki puta vrti a "i" koristi... 
			{pArray [i][l] = s2[l];}  // ...od odozgor
		
	s2.erase();						//"s2.erase();"ovo je potrebno da se string svaki puta ocisti jer bez brisanja
}									//dolazi do nagomilavanja a ne da mi kida primer u male dijelove za usporedbu

}


int _tmain(int argc, _TCHAR* argv[])
{
	string S1, s2;
	S1=("nestjakomajosiima");
twodymArray theobj(S1,4);
cout<<"Row = "<<theobj.Row<<" Column = "<<theobj.Column<<" Primer = "<<theobj.primer<<endl;




//for(int i=0; i<(theobj.Row-(theobj.Column-1)); i++)			//formula (row-(letters-1)) je nuzna da ne izadje izvan
//{												//polja a daje broj koliko ce se "usporedjica" napraviti
//		for (int j=0; j<theobj.Column; j++)  //for petlja je skraceni oblik pisanja [i+1] + [i+2] +....
//		{s2 = s2 + theobj.primer[i+j];}	  //jer tako unosom varijable letters mogu dobit potreban broj ponavljanja
//		
//			for (int l=0; l<theobj.Column; l++)  //upisuje stringove s2 u "array". "l" petlju svaki puta vrti a "i" koristi... 
//			{theobj.pArray [i][l] = s2[l];}  // ...od odozgor
//		
//	s2.erase();						//"s2.erase();"ovo je potrebno da se string svaki puta ocisti jer bez brisanja
//}		


for (int m=0; m<(theobj.Row-(theobj.Column-1)); m++) //
		{
			for (int n=0; n<theobj.Column; n++)
				{cout<<theobj.pArray[m][n];}
		cout<<endl;
		}

system("PAUSE");
	return 0;
}

Something like this?

void fill_array(char **array, int xs, int ys, char set) {
    for(int x = 0; x < xs; x ++) {
        for(int y = 0; y < ys; y ++) {
            array[xs][ys] = set;
        }
    }
}

Maybe you haven't seen but I already had tried this with char **array, but it doesn't work. Probably I must do something with “unnamed temporary but I don’t know how!
Anyway thank you for replay!

This article has been dead for over six months. Start a new discussion instead.