Please help me to find error in this program .I am trying to add data to a dynamic ar

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 64
Reputation: vijaysoft1 is an unknown quantity at this point 
Solved Threads: 0
vijaysoft1's Avatar
vijaysoft1 vijaysoft1 is offline Offline
Junior Poster in Training

Please help me to find error in this program .I am trying to add data to a dynamic ar

 
0
  #1
Aug 28th, 2008
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;


	}
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Please help me to find error in this program .I am trying to add data to a dynamic ar

 
0
  #2
Aug 28th, 2008
Honestly speaking it looks like an absolutely senseless text written in unknown language.
May be better you present your assignment?..
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 1,674
Reputation: vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold vmanes is a splendid one to behold 
Solved Threads: 193
vmanes's Avatar
vmanes vmanes is offline Offline
Posting Virtuoso

Re: Please help me to find error in this program .I am trying to add data to a dynamic ar

 
0
  #3
Aug 28th, 2008
  1. dynamicarray = new char(Size([20]);
  2. dynamicarray = tmp;

There's a classic error. Why is it so?
"We Americans got so tired of being thought of as dumb by the rest of the world that we went to the polls last November and removed all doubt."
~~~~~~~~~~~~~~~~~~
Looking for an exciting graduate degree? Robotics and Intelligent Autonomous Systems (RIAS) at SDSM&T See the program brochure here.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: Please help me to find error in this program .I am trying to add data to a dynamic ar

 
0
  #4
Aug 30th, 2008
your code :
  1. dynamicarray = new char(Size([20]);

my code :
  1. ...
  2. dynamicarray = new char(Size([20])); // <-- ???
  3. //--or
  4. dynamicarray = new char(Size(20));
  5. //--or
  6. dynamicarray = new char[20];
Last edited by cikara21; Aug 30th, 2008 at 2:06 am.
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC