Character and String
char:
- is one of the fundamental types; the lowest level unit of a program(input,output,and program); problem of special character e.g. space, escape, return , alt etc.; require special handling i.e. getchar() and putchar()
- <ctype.h> header file contains all the prototypes of the charater handling functions such as isupper(Ch), isalpha(Ch), iscntrl(Ch) etc.
string:
- a one dimensional array of char, which is terminated by the end-of-string sentinel \0; eg. char w[100];
- Note: 'a' ? "a", 'a' is a character constant, and the second is a string constant with 2 elements: 'a' and '\0'.
- One way to get character values into w is to do it character by character: w[0] = 'A';w[1] = 'B';w[2] = 'C';w[3] = '\0';
- char s[] = "abc"; ? char s[] = {'a','b','c','\0'};
- Another way is to make use of scanf(). ie. scanf("%s",w);
- Similarly, <string.h> header file contains all the prototypes of the string handling functions. eg. strcat(), strcmp(), strcpy(), strlrn() etc.