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
Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.
What are the advantages of using macro in c language?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
How is null defined in c?
What is variables in c?
What are structures and unions? State differencves between them.
What are the types of type qualifiers in c?
What is the best organizational structure?
What functions are used in dynamic memory allocation in c?
What is c preprocessor mean?
write a program to display all prime numbers
When is a void pointer used?
Write a c program to build a heap method using Pointer to function and pointer to structure ?
Explain how do you declare an array that will hold more than 64kb of data?
Why string is used in c?