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


Please Help Members By Posting Answers For Below Questions

Who developed c language and when?

815


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

2063


What are the types of macro formats?

798


write an algorithm to display a square matrix.

2421


what type of questions arrive in interview over c programming?

1763


How many types of operator or there in c?

830


Describe the steps to insert data into a singly linked list.

816


What are local static variables? How can you use them?

837


Is it possible to have a function as a parameter in another function?

823


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2629


What are the main characteristics of c language describe the structure of ac program?

926


How can I swap two values without using a temporary?

815


How do you override a defined macro?

892


Write a client and server program in C language using UDP, where client program interact with the Server as given below: i) The client begins by sending a request to send a string of 8 characters or series of 7 numbers, the server sends back a characters or numbers as per the request of the client. ii) In case of series of 7 numbers: The client sends a multiplication of numbers, to the server. iii) In case of a string of 8 characters: The client sends a reverse order of string to the server.. iv) Server will send an acknowledgment to the client after receiving the correct answer

4088


Explain argument and its types.

782