GeekInterview.com
Series: Subject: Topic:
Question: 369 of 827

What is the difference between character array and string in C?

Asked by: ravi.dokania | Member Since Jan-2007 | Asked on: Feb 5th, 2007

View all questions by ravi.dokania   View all answers by ravi.dokania

Showing Answers 1 - 5 of 5 Answers
malaram

Answered On : Feb 6th, 2007

View all answers by malaram

I think there is nothing difference b/w both because string is a collection of character or we can say it is a character array which ends at NULL.

  
Login to rate this answer.
Amit_21

Answered On : Jan 31st, 2008

View all answers by Amit_21

IN C there is no big diffrence Between string and character array  but string must be NULL terminated...... if u ll forget to insert the '' at the END it will automatically insert the NULL chracter .take a exampleint i;char arr[5]={'a','s','d','z','x'};  \no error because not a string..it is collection of chracterchar arr1[5]="asdzx";   //error overflow because last chracter must be char arr2[6]="asdzx";//will workfor (i=0;i<5;printf("n%d----%cn",i,arr[i]),i++);printf("nstringn ");printf("nstring-----is ----%sn",arr1);hi,guys..this is amit what i feel abto arrayand string i already written ..if u have any other views plz send me at amitsrms21@gmail.com

  
Login to rate this answer.
vanavill

Answered On : Feb 8th, 2008

View all answers by vanavill

 Hai,    string is a collection of charecter,it must be ended with null.      charecter array is aset of elements if you didn't give a space for null,it shows error.       if any correction or further infn plz send it to me.regrads,bala.

  
Login to rate this answer.
kushal

Answered On : Dec 26th, 2011

Char arr2[6]="asdzx";//will work


this instruction never work....
ok

  
Login to rate this answer.
udaykiran

Answered On : Feb 8th, 2012

The major difference between the char array and the string is that the array will not end with the null....where as string ends with the null.............

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.