answersLogoWhite

0

What is the difference between string and char array?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

3 differences..................

1. length wise....

2.initialization

3. null terminated

length of char array is differ from string........

initialization of string is differ from char.......

and string is null terminated...........

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

What is your understanding of structures? Discuss how structures work in programming

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between string and char array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between Strings and Arrays in c?

There is no difference. A string is just an array of type char. The only real difference is that we do not need to keep track of the length of a string because strings are null-terminated in C. If a string does not have a null-terminator, then it is just an ordinary array of character values.


What is the difference between a C plus plus string and a C-style string?

A std::string is an object that encapsulates an array of type char whereas a C-style string is a primitive array with no members. A std::string is guaranteed to be null-terminated but a C-style string is not.


How many constructors are there for the string class?

The String class has multiple Constructors. Some of them are: 1. String - new String(String val) 2. Character Array - new String(char[] array) 3. Character Array with index positions - new String(char[] array. int start, int end)


What is the difference between Char a equals string and char a equals String?

Well, if you write like char a=string; it is wrong. You have to declare the size of the array or else put the brackets immediately after the variable declaration. You also have to put the string in quotes, or provide a comma-separated list of characters. E.g.,char a[]={'s','t','r','i','n','g'};Or more simply:char a[] = "string";Remember that C/C++ is case-sensitive and that all keywords are lower case. Thus Char would be regarded as an invalid keyword.


What is return type of string in c?

In C programming, a string doesn't have a specific return type as it's essentially an array of characters. So, if a function is returning a string, it should be declared to return a pointer to a char (char*), since a string in C is represented as an array of characters terminated by a null character ('\0').


What is a sequence of characters?

A sequence of characters is an array of type char, commonly known as a string.


In java is A string the same thing as a char?

No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.No.A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.


What are the different between'a' and ''a in java string methods?

The difference between 'a' and "a" anywhere in Java is that 'a' is a primitive char type, while "a" is a String object.


How do you store a string of letters for example abcdeabcde each to an array?

In C programming you would use the following: char a[] = "abcdeabcde"; If you wish to create an array with more than one string, use an array of character pointers instead: char* a[] = {"abcde", "fgh", "ijklm", "nopq", "rstu", "vwxyz"};


Can you give an example of array using character variable in c program?

the example of array over charcter variables is char ["string"]


What is the difference between string type and character type constants?

A character type constant is a character, a char, while a string type is an array of characters. The character type constant is one character and is delimited by single quotes. The string type constant is zero or more characters and is delimited by double quotes.


What do you mean by string in c language?

Character arrays or pointers to character are termed as strings in c language. Like:char arr[10] = {'s', 't', 'i', 'n', 'g'};char *pchar = "string";Above answer is the first answer for the questionBut there is a lot of difference between character array and string.string means a group of characters .And string is enclosed between double quotation marks i.e(" ") .Declaration of string is same as of char array ,which is as followschar str[20];And initialization is different from that of character arrayinitialization:-char str[7]={"vardhan"};