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

Is stack a keyword in c?

1080


What is the significance of scope resolution operator?

1410


What is the function of this pointer?

1339


What is the size of enum in c?

1119


What is LINKED LIST? How can you access the last element in a linked list?

1071


What is the -> in c?

1012


What is #line used for?

1026


What is pointer to pointer in c language?

1146


can any one tel me wt is the question pattern for NIC exam

1976


why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above

1155


What is variable declaration and definition in c?

898


Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

2294


Is there a way to jump out of a function or functions?

1095


If you know then define #pragma?

1104


Tell me what is null pointer in c?

1080