beautypg.com

5-4. standard i/o examples – Oki JOB60851 User Manual

Page 66

background image

Chapter 4 Software Development

page 4-31

4-5-4.

Standard I/O Examples

This Section presents examples actually using this standard I/O.

For further details on the printf_c(), puts(), and gets() library functions used, refer to the RTL665S
Run-Time Library Reference.

(1) Using standard output and write()

Section 2-3. "Running User Programs" gives one example of a program that writes to standard
output. The following is another.

For further details on the printf_c() and puts() library functions used, refer to the RTL665S
Run-Time Library Reference.

Sample Program Using Standard Output

/* Read/Write sample program 1 */

/* Filename:rw_smpl1.c */

/* Copyright(C) 1999 TECHNOCOLLAGE,Inc. All right reserved. */

#include

#include

#include

void main(void)

{

int day;

char *d_name[] = {

"Sunday : Sunday",

"Monday : Monday",

"Tuesday : Tuesday",

"Wednesday : Wednesday",

"Thursday : Thursday",

"Friday : Friday",

"Saturday : Saturday"};

/* Initialize MSM66Q573 */

std_init_573();

S0BUF = 0x0A;

/* Main display loop */

for(day=0;day<7;day++)

{

puts(d_name[day]);

/* Send string to standard output */

}

}

(2) Using standard input and read()

The following source codes is an example of a program that reads from standard input.

For further details on the printf_c() and gets() library functions used, refer to the RTL665S Run-
Time Library Reference.