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

Why isn't it being handled properly?

1074


What is the difference between malloc() and calloc() function in c language?

1091


Is a pointer a kind of array?

1193


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

2068


Why do we use stdio h and conio h?

1101


What does the error message "DGROUP exceeds 64K" mean?

1234


What’s a signal? Explain what do I use signals for?

1119


Can i use “int” data type to store the value 32768? Why?

1194


The file stdio.h, what does it contain?

1173


How can I do graphics in c?

1039


What is enumerated data type in c?

1088


Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?

1071


How will you divide two numbers in a MACRO?

1144


What are operators in c?

1033


Explain data types & how many data types supported by c?

1089