Chapter 9. Internal Processing and File I/O
80
$ ./length i (a Hangul character)
Your string is: "(the character)"
Length of your string is: 3 bytes.
Length of your string is: 1 characters.
Width of your string is: 2 columns.
9.4 Extraction of Characters
The following program extracts all characters contained in the given string.
/* extract.c
*
* a sample program to extract each character contained in the string
* not internationalized
*/
#include
#include
int main(int argc, char **argv)
{
char *p;
int c;
if (argc < 2) {
printf("Usage: %s [string]\n", argv[0]);
return 0;
}
printf("Your string is: \"%s\".\n", argv[1]);
c = 0;
for (p=argv[1] ; *p ; p++) {
printf("Character #%d is \"%c\".\n", ++c, *p);
}
return 0;
}
Using wide characters, the program can be rewritten as following.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Inexpensive Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Jsp Hosting
Cheap Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved