DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Please help me to find error in this program .I am trying to add data to a dynamic ar (http://www.daniweb.com/forums/thread142842.html)

vijaysoft1 Aug 28th, 2008 2:26 pm
Please help me to find error in this program .I am trying to add data to a dynamic ar
 
Please help me to find error in this program .I am trying to add data to a dynamic array .



#include<iostream.h>
#include<conio.h>
#include<string.h>

class data
{
        private:

                char(* dynamicarray)[20];
                int size1,i;

        public:

                data(char(*tmp)[20],int Size)
                {
                        dynamicarray = new char(Size([20]);
                        dynamicarray = tmp;
                        size1 = Size;
                }
                get()
                {
                        for(i=0;i<size1;i++)
                        {
                                cout<<dynamicarray[i];
                        }
                }
        };


        main()


        {
                char array1[5][20] ={"tom","dick"};
                int Size1 =5;
                data obj;
                obj.data(array1,Size1);
                data g;
                obj.get();
                return 0;


        }

ArkM Aug 28th, 2008 3:55 pm
Re: Please help me to find error in this program .I am trying to add data to a dynamic ar
 
Honestly speaking it looks like an absolutely senseless text written in unknown language.
May be better you present your assignment?..

vmanes Aug 28th, 2008 4:32 pm
Re: Please help me to find error in this program .I am trying to add data to a dynamic ar
 
dynamicarray = new char(Size([20]);
dynamicarray = tmp;

There's a classic error. Why is it so?

cikara21 Aug 30th, 2008 12:48 am
Re: Please help me to find error in this program .I am trying to add data to a dynamic ar
 
your code :
dynamicarray = new char(Size([20]);

my code :
...
dynamicarray = new char(Size([20])); // <-- ???
//--or
dynamicarray = new char(Size(20));
//--or
dynamicarray = new char[20];


All times are GMT -4. The time now is 11:17 pm.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC