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 #include preprocessor?
What is the code in while loop that returns the output of given code?
I need testPalindrome and removeSpace
#include
Why #include is used in c language?
Is it cc or c in a letter?
How would you obtain the current time and difference between two times?
What is malloc calloc and realloc in c?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What does nil mean in c?
What is a file descriptor in c?
struct screen_pos{ int row, col } ;move_right(cursor)struct screen_pos *cursor;{ cursor.col++; } /* This statementhas a syntax error */What is the correct statement a) cursor.col = cursor.col + 1; b) col.cursor++; c) *cursor.col++; d) pointer
Explain how do you declare an array that will hold more than 64kb of data?
Can you please explain the difference between exit() and _exit() function?
In C language, a variable name cannot contain?
What is difference between Structure and Unions?