Rockwell-automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User M Manual de usuario Pagina 59

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 312
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 58
Chapter 4

4-7
Example Program to Access RAM Disk
Refer to the following C program (CAT.C) as an example of accessing
the control-coprocessor RAM disk. Note the use of standard C library
functions—e.g.,
fopen(), getc(), and fclose()—to access RAM-
disk files.
You create the file, compile it, and send it to OS-9 as a binary file.
Then, you run the C program on OS-9.
/***** cat.c ::: copy from files to standard out *****
*
* This program is used as an example so you can learn to use the
* Standard Library functions for processing characters from an
* input file and writing characters on the standard output,
* and so you can use a command in a “pipeline” with redirection
* modifiers (’<’ and ’>’). Try doing a:
*
* cat file1 file2 file3 > outfile
*
* type of operation to see how “cat” can merge files...
*
* “What goes around, comes around.”
*/
/* First, includes and defines... */
#include <stdio.h> /* needed for ’getc()’ and ’putchar()’ */
#include <errno.h> /* needed for ’errno’ to work */
/* then the function and parameter declarations... */
main ( argc, argv )
int argc;
char **argv;
/* then the body of executable function statements... */
{
/* private variable declarations */
FILE *infil; /* file to copy to standard output */
int c, /* character (or EOF) gotten from input file */
i; /* which command line argument is being processed */
/*
* This command has no option switches. It simply copies the
* input file(s) character by character to standard output.
* If only the command itself is specified, it does nothing.
* Probably better tell the user such...!
*/
if ( argc == 1 ) /* no file names on command line */
{
fprintf ( stderr, “No files on command line. Exiting.\n” );
exit ( 0 );
}
Vista de pagina 58
1 2 ... 54 55 56 57 58 59 60 61 62 63 64 ... 311 312

Comentarios a estos manuales

Sin comentarios