what is difference between array of characters and string

Answers were Sorted based on User's Feedback



what is difference between array of characters and string..

Answer / vedavathi

when we declare array of character it has 2 be teminated by
null,but termination by null in case of string is automatic.

Is This Answer Correct ?    93 Yes 23 No

what is difference between array of characters and string..

Answer / kapil kumar verma iimt meerut

when we declare array of char it has to be terminated by
null but termination by null in case of string is
automatic.the compiler automatically puts a null char when
we insert a string for example "kapil" for the
string "kapil\0", but for a char array we need assign a
place for it for example a[6] contains five char & a null
char.& secondly
when char array is read through scanf() input function then
spaces are not allowed if characters is read as string
(through gets() function) spaces are allowedand are treated
as a single char.

Is This Answer Correct ?    38 Yes 4 No

what is difference between array of characters and string..

Answer / zubair

String is much same as character array, it can also be
checked by each characters:
string str;for(int i=0;str[i]!='\0';i++) cout <<str[i]<<endl;

1. The NULL terminator is loaded automatically in string.('\0')
2.Both of them drop the data after space when we take input.

Is This Answer Correct ?    35 Yes 4 No

what is difference between array of characters and string..

Answer / vijay

we can store set of names in string.but can only store set
of characters in array

Is This Answer Correct ?    77 Yes 55 No

what is difference between array of characters and string..

Answer / saumil

the compiler automatically puts a null character when we
insert a string...for eg "abc" for the compiler is "abc\0".
but for a array of characters we need to assign a place for
it..for eg a[15] contains 14 characters and a null
character('\0').

Is This Answer Correct ?    24 Yes 7 No

what is difference between array of characters and string..

Answer / punit shukla,hbti-kanpur

1.major difference is: string will have static storage
duration, whereas as a character array will not, unless it
is explicity specified by using the static keyword.
2.Two strings of same value[1] may share same memory area
bt not in the case of char arrays

Is This Answer Correct ?    11 Yes 3 No

what is difference between array of characters and string..

Answer / guest

in char array space are not allowed means part after space
not consider but in string it is allowed

Is This Answer Correct ?    31 Yes 26 No

what is difference between array of characters and string..

Answer / shruti

In case of a string, we cant print each character by
character whereas for arrays of char we can do that.

String is terminated by a NULL character by default.
in array we have to explicitly do that.

Is This Answer Correct ?    20 Yes 16 No

what is difference between array of characters and string..

Answer / nag

Character array consist of group of characters, and static one
char a[10] means 9 are for using purpose and one is null
In case of string null is taken as default and is taken into
double quotes
String s="string";

Is This Answer Correct ?    5 Yes 1 No

what is difference between array of characters and string..

Answer / shayan

the main difference between array of char and string is that when we declare array of char like char name[6],in this case for example shayan s is stored in 0 index and last character is n which is at 5 index but i delared 6 because 6th index is of null character which is neccesary to declare but in string it will automatically declare by the compiler like "shayan" after n compiler automatically put \0 after n.

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

What is a char c?

0 Answers  


what is the use of ‘auto’ keyword?

1 Answers  


What are the advantages and disadvantages of c language?

0 Answers  


What header files do I need in order to define the standard library functions I use?

0 Answers  


int x=5; printf("%d%d%d",x,x<<2,x>>2);

2 Answers   TANCET,






How do you initialize function pointers? Give an example?

3 Answers  


I have one doubt. What does below statement mean? #define sizeof(operator) where operator can be int or float etc. Does this statement meaningful and where it can be used?

1 Answers  


Can an array be an Ivalue?

0 Answers   EXL,


What are predefined functions in c?

0 Answers  


number 2 plssssss help !!....using array.. turbo c.. create a program that will accept a number and determine if it is a happy number or an unhappy number.. example: enter a number : 7 7*7=49 then 4 and 9 4*4 and 9*9== 16 + 18 gives you 97 then 9 and 7 9*9 and 7*7 == 81 + 49 gives you 130 then 1 and 3 1*1 and 3*3 == 1 + 9 gives you 10 1*1 gives you 1 sample output: 7= 49= 16+81= 97= 81+49=130 =1+9=10 =1 "7 is a happy number" . if the last number is 2 then the number being inputed is not a happy number.

3 Answers  


Write a program to display the no of bit difference between any 2 given numbers eg: Num1 will 12->1100 Num2 will 7->0111 the difference in bits are 2.

4 Answers  


difference between c and c++?

2 Answers  


Categories