Isnt it possible to have the array GLOBAL and then point to that array
as a return value? (I cant remember.)
I only know this (that C/C++ is very poor in usage of pointer and the
like. Realy.)
Maybe, this is helpful:
Read always from the right-to-the-left. But as a C/C++ programmer, you
should bekome R-T-L (right-to-left) reader/writer. Like the hebrew language.
1. *Declaration*
int *zeig_1; // Read: zeig_1 is a pointer to int.
// There is nothing "in it", its just a declaration here.
2. *Do something*. *Point to someting*.
zeig_1 = &var_1; // 'zeig_1' points to the variable 'var_1'
// in zeig_1 is now the memory-address stored
// of where var_1 is.
*Example*:
int var_1; // an int
int var_2; // another int
int *zeig_1; // a pointer to int (read from right-to-left)
int var_1 = 4; // 'var_1' = 4
zeig_1 = &var_1; // setup pointer to point to the int variable.
// read: var_1 is an address. zeig_1 IS/contains now
// this address. And AT this address, there is an int
// value of 4 stored. --- You must think in
// assemble/machine code...
var_2 = *zeig_1; // Now. var_2 is the value where zeig_1
// points to.
*zeig_1 = 7; // change the value, where zeig_1 points to, to 7.
// So, this was nice.
// ( *zeig_1 is var_1 )
In C/C++, you must think like in assembler/machine-code... and how the
things are layouted there pysically... ;-)
*What happend in the memory is this*:
-----------
<< zeig_1 >>
-----------
||
\/
----------- -----------
< var_1 > < var_2 >
----------- -----------
| |
v v
----------- -----------
| 4 : 7 | | 4 |
----------- -----------
*You can also have things like that*:
int x; // x is an int
int *pi; // pi is a pointer to int
int * const cpi = &x; // cpi is a constant pointer to int.
// and will be initialized, that it
// points to x (this is the address of x).
//
*NOTE*:
Read here:
1. the left side of the "="-sign from right to left.
2. then read the right side of the "="-sign, also from the
right-to-the-left. ;-)
C/C++ brainwashed my mind.
> Hello
>
> I want to write a function which returns a char array.
>
> But if I write this:
>
> char[] myfunction()
> {
> return "123";
> }
>
> I get a C4091 warning and a C2143 error on compiling. so how do I write a
> function which returns a char array?
>
>