For either short or int, -32767 to +32767 is guaranteed.
Printable View
For signed, yes. For unsigned, that would be 0 - 65535.
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
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;
}
Yes, it would work fine, but not the best solution. To return constant data, consider making it static to your function instead.
That way you avoid global variables.
Thanks.
What about
static const char* string[] = .... ?
> static const char* string[] = .... ?
Did you really want an array of read-only strings?