to solve the 1st - just add () to function to indicate the call of the function
About the second - when you return something like
return "some const string";
you returning pointer to const string that will not be destructed, so its OK...
If you are creating the string inside your function - its another story
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
I understand. So this would be fine
Thanks for you help!Code:const char *text[] = {"memory","information"}; int main() { while(i<100) { ... printf("Example %s\n",function()); ... i++; } return 0; } char* function () { char* data; ... data = text[0]; .... return data; }
Thanks.
What about
static const char* string[] = .... ?
> static const char* string[] = .... ?
Did you really want an array of read-only strings?
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler