You are really confusing people Leibnitz!
First, you return a local variable, which gets toatlly destroyed after leaving the program body where got declared!
But, you've corrected that.
I'll pass the second error of trying to do anything after returning from a function.
Third, you allocate an array dynamically and you assign to it a const pointer???? Not that the program would crash if you do that... but is the next step comparing strings with equal sign?? Nevermind the fact that you return from the function a GLOBAL VARIABLE!!! Why bother?
I don't have anything personal with you, but, if you decide to post, be sure first you know what you are doing. If you are not sure, please test your replies first, or else, you have the chance of confusing innocent beginners and give them awful time.
-----------------------------------------------------------
To finally answer Mauraders' question:
to understand what is going on, be sure first you familiarize yourself with pointers as they are the only way of returning a vector from an array.
See my previous reply to you.
How does a pointer to an int translate into vector? Well, pointers just point at memory areas. You then can parse that memory area, but you have to be carefull not to cross vector's boundaries.
To get to my last example, here it is, completed:
Code:
int *returnVector(int &dimension) {
dimension = 100;
int *ret = new int[dimension];
return ret;
};
void main()
{ int dim,i;
int *vec = returnVector(dim);
for (i = 0; i < dim; i++)
printf("vec[%d] = %d\n",i,vec[i]);
getch();
}
HTH
[red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro