Character.toString('c')
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
Use the tolower() function. Example: char* a = 'X'; a = tolower(a); printf("%c", a);
char *string = "this is a test"; char *p; for (p=string; *p!='\0'; p++) if (*p==' ') *p='-';
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...........
char *strmerge (char *s3, const char *s1, const char *s2) { strcpy (s3, s1); strcat (s3, s2); return s3; }
You can use the methods toUpperCase & toLowerCase to convert Strings to any case you want.
You can't convert the data type of any variable.
C forbids converting a string constant to 'char' because string constants are stored in read-only memory, and attempting to modify them through a 'char' pointer can lead to undefined behavior and potential program crashes.
char is used in Java to enetr only one character but string is used to specify a whole sentence or a bunch of characters.
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; }
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.