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 is a program flowchart and how does it help in writing a program?
What is dangling pointer in c?
Which node is more powerful and can handle local information processing or graphics processing?
What are global variables and how do you declare them?
Explain indirection?
all c language question
what are the different storage classes in c?
Why is it important to memset a variable, immediately after allocating memory to it ?
How does struct work in c?
Explain what is the purpose of "extern" keyword in a function declaration?
What is difference between constant pointer and constant variable?
Explain how can I open a file so that other programs can update it at the same time?
What are the advantages of union?
What are the advantages of using Unions?
What are the different types of control structures in programming?