Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Go through the following code sinippet
char a[20];
a="Hello Orcale Test";
will this compile?

Answer Posted / pradeep

Dear frd,

char a[20];
a="Hello Orcale Test";

Here you are trying to "assign" constant char string to
address variable , as you are aware that name of an array
points to the first address of the array element. So here
you wil get an error message saying L value is required.

and also
char *a;
*a="hello" ; also will give an error as you are trying to
assign constant characters to char type variable.
Type mismatch will occur.

so I suggest you to use the strcpy method to copy a
constant character string to char*

so soln is
char a[20];
strcpy(a,"hello world");

or char *a;
a="hello";

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is ctrl c called?

1002


Can you write a programmer for FACTORIAL using recursion?

985


#include { printf("Hello"); } how compile time affects when we add additional header file .

1852


What is pointer and structure in c?

1073


Tell me when would you use a pointer to a function?

1011


What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25

1936


Explain how do you override a defined macro?

1019


Explain what is a program flowchart and explain how does it help in writing a program?

1043


What is an example of structure?

981


Is stack a keyword in c?

1038


Difference between macros and inline functions? Can a function be forced as inline?

1201


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

3018


Explain union.

1114


How many bytes are occupied by near, far and huge pointers (dos)?

1115


i want to know the procedure of qualcomm for getting a job through offcampus

2409