0

Hey, I am working on a project and I want to know how to return a class object that is a Character Array. I am having trouble with it and can't find out any way to do this. Thank you for taking the time to help (:

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by triumphost
0

Just change your vector to array/char*.. it'll do the same thing.

class SomeObjectClass
{
	private:
		vector<char> DataHolder;
	public:
		SomeObjectClass(){}
		~SomeObjectClass(){}
		
	vector<char> SomeFunc(SomeObject &Obj)
	{
		return DataHolder;
	}
};

Edited by triumphost: n/a

0

I am not using a vector. I need to change a character array into a variable integer.

0

What? Char Array to Int Array you mean?

//Our Char Array..
char Returned[5];
int IntArr = new int[sizeof(Returned);

for (int I = 0; I < sizeof(Returned); I++)
   IntArr[I] = (int)Returned[I];
  
for (int I = 0; I < sizeof(IntArr)/sizeof(int); I++)
   cout<<IntArr[I];

delete [] IntArr;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.