answersLogoWhite

0

What is the different between char and string?

Updated: 8/18/2019
User Avatar

Wiki User

13y ago

Best Answer

char is used in Java to enetr only one character but string is used to specify a whole sentence or a bunch of characters.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

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

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.


What is the difference between string and char array?

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...........


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.


'c' code to compare two strings using strcmp function?

char one [] = "A string" ;char two [] = "Different String" ;if (strcmp (one, two) == 0){puts ("The two strings are identical") ;}else{puts ("The two strings are different") ;}


How do you convert char to String in java?

A String is nothing but a bunch of characters one after the other whereas a character has a size of only '1' So converting a string into a char is not possible. what you can do is form a character based on only one element from the string. Ex: String name = "Rocky"; char xyz = name.charAt(0); now the char xyz will have one character from the String.


C prog to concatenate two string without using buid in function?

//String Concatination#include#includeusing namespace std;char* strcat(char*,char*);int main(){char str1[100];char str2[100];coutstr1;coutstr2;cout


C plus plus programs - to replace every space in a string with a hyphen?

char *string = "this is a test"; char *p; for (p=string; *p!='\0'; p++) if (*p==' ') *p='-';


How do you convert char to string?

Character.toString('c')


Write a function for concatnating the string s1 s2 and storing the result in string s3?

char *strmerge (char *s3, const char *s1, const char *s2) { strcpy (s3, s1); strcat (s3, s2); return s3; }


How do you reverse a string in C?

Code example:/* ******************************************************************************** * FUNCTION: cpReverseStr ******************************************************************************** * DESCRIPTION: * Reverses a given string. Overwrites original. * * PARAMETERS: * cpString: The string to reverse. * * RETURNS: * Reversed string. ******************************************************************************** */ char * cpReverseStr( char *cpString) { register char cTmp; register char *cpFirst = cpString; register char *cpLast = cpFirst + strlen(cpString) - 1; while(cpFirst < cpLast) { cTmp = *cpFirst; *cpFirst = *cpLast; *cpLast = cTmp; cpFirst++; cpLast--; } return cpString; }


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 do you return a word in a string so that every letter is a symbol eg egg must be 3 symbols?

Not really sure what you mean by symbol. I will assume that you are talking about a character Here is a method that will seperate each char of a String in an array of char public char[] seperateChar(String s) { char [] c = new char[s.length]; for(int i = 0; i &lt; s.length(); i++) { c[i] = s.charAt(i); } return c }