Chapter 9. Internal Processing and File I/O
77
printf("%d characters, %d digits, %d words, and %d lines\n",
c, d, w, l);
}
Here is the internationalized version.
/*
*
wc i.c
*
*
Word Counter (internationalized version)
*
*/
#include 
#include 
#include 
int main(int argc, char **argv)
{
int p=0, d=0, c=0, w=0, l=0;
wint_t n;
setlocale(LC_ALL, "");
while ((n=getwchar()) != EOF) {
c++;
if (iswdigit(n)) d++;
if (wcschr(L" \t\n", n)) w++;
if (n == L'\n') l++;
}
printf("%d characters, %d digits, %d words, and %d lines\n",
c, d, w, l);
}
This example shows that
iswdigit()
is used instead of
isdigit()
. And more,
L string 
and
L'char'
for wide character string and wide character.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

indiana web hosting

 

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