Whats wrong with the following function
char *string()
{
char *text[20];
strcpy(text,"Hello world");
return text;
}
Answer Posted / vignesh1988i
as for as i know , there is only one error..... you have
declared text as array of pointers and not as character data
array..... so this text can only accept addresses.... :)
char *text[20] means you are going to store 20 addresses in
this array..... When you store addresses using arrays , the
that is called array of pointers....
if u declare : char text[20] , this will work correctly..
thank u
Is This Answer Correct ? | 13 Yes | 2 No |
Post New Answer View All Answers
What language is c written?
Explain what is a const pointer?
What does %c mean in c?
What is the difference between int main and void main in c?
How do you print an address?
State the difference between realloc and free.
What is zero based addressing?
How do you define CONSTANT in C?
Write a program on swapping (100, 50)
What is the use of define in c?
How can you call a function, given its name as a string?
Write a c program to demonstrate character and string constants?
Explain why c is faster than c++?
Can we access array using pointer in c language?
Is there sort function in c?