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 the advantage of a random access file?
What are the complete rules for header file searching?
What is define directive?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What kind of structure is a house?
What is the right way to use errno?
What are the applications of c language?
What are structure members?
How can you tell whether a program was compiled using c versus c++?
What are the preprocessor categories?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
How would you rename a function in C?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters