HP 9000 User Manual page 154

Computers
Hide thumbs Also See for 9000:
Table of Contents

Advertisement

The following program works only for single-byte characters because two-byte
characters can potentially be split between bytes and treated as single-byte
codes.
#include <stdio.h>
#include <locale.h>
#define
WIDTH
5
main (argc, argv)
int
argc;
char **argv;
{
}
unsigned char output_array
[WIDTH] ,
*output_ptr, *input_ptr;
int c, counter;
1*
try to set the locale, even through it does not affect the program
because there are no calls to routines that are affected by the locale
*1
if
(!
setlocale(LC_ALL,"I» {
fprintf(stderr,"error: cannot set locale\n");
}
input_ptr = argv[l];
counter = 0;
output_ptr = output_array;
while (c = *input_ptr++) {
if (counter >=
WIDTH {
}
*output_ptr = '\0';
puts(output_array);
counter = 0;
output_ptr = output_array;
/* initialize the pointers and counter
*1
1*
get a char until end of string */
1*
if output array is complete, process it
*1
1*
null terminate the output array */
1*
print the output array */
1*
reset counter */
1*
reset output pointer to beginning
of array */
counter++;
1*
if output array not complete
increment counter */
*output_ptr++ = c;
1*
set area pointed to by output_ptr
to c, then increment output_ptr */
}
*output_ptr = '\0';
puts(output_array);
1*
null terminate the output array */
1*
print the output array */
Special Topics for HP's 16-bit Interfaces A-7
A

Advertisement

Table of Contents
loading

Table of Contents