char is used in Java to enetr only one character but string is used to specify a whole sentence or a bunch of characters.
The difference between 'a' and "a" anywhere in Java is that 'a' is a primitive char type, while "a" is a String object.
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...........
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.
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") ;}
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.
//String Concatination#include#includeusing namespace std;char* strcat(char*,char*);int main(){char str1[100];char str2[100];coutstr1;coutstr2;cout
char *string = "this is a test"; char *p; for (p=string; *p!='\0'; p++) if (*p==' ') *p='-';
Character.toString('c')
char *strmerge (char *s3, const char *s1, const char *s2) { strcpy (s3, s1); strcat (s3, s2); return s3; }
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; }
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.
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 < s.length(); i++) { c[i] = s.charAt(i); } return c }