Chapter 9. Internal Processing and File I/O
78
9.3 Length of String
The following is a sample program to obtain the length of the inputed string. Note that number
of bytes and number of characters are not distinguished.
/* length.c
*
* a sample program to obtain the length of the inputed string
* NOT INTERNATIONALIZED
*/
#include 
#include 
int main(int argc, char **argv)
{
int len;
if (argc < 2) {
printf("Usage: %s [string]\n", argv[0]);
return 0;
}
printf("Your string is: \"%s\".\n", argv[1]);
len = strlen(argv[1]);
printf("Length of your string is: %d bytes.\n", len);
printf("Length of your string is: %d characters.\n", len);
printf("Width of your string is: %d columns.\n", len);
return 0;
}
The following is a internationalized version of the program using wide characters.
/* length i.c
*
* a sample program to obtain the length of the inputed string
* INTERNATIONALIZED
*/
#include 






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