_Rpgmdev () -設定預設程式裝置
格式
#include <recio.h>
int _Rpgmdev(_RFILE *fp, char *dev);語言層次
ILE C 延伸
安全執行緒
否
工作 CCSID 介面
傳送至此功能的所有字元資料都預期在工作的 CCSID 中。 此函數傳回的所有字元資料都在工作的 CCSID 中。 如需相關資訊,請參閱 瞭解 CCSID 及語言環境 。
說明
_Rpgmdev() 函數會將與 fp 相關聯之檔案的現行程式裝置設為 dev。 您必須以大寫指定裝置。
dev 參數是空值結束的 C 字串。
_Rpgmdev() 功能適用於顯示器、ICF 及印表機檔案。
回覆值
範例
#include <stdio.h>
#include <recio.h>
#include <string.h>
#include <stdlib.h>
typedef struct {
char name[20];
char address[25];
} format1 ;
typedef struct {
char name[8];
char password[10];
} format2 ;
typedef union {
format1 fmt1;
format2 fmt2;
} formats ;
int main(void)
{
_RFILE *fp; /* File pointer */
_RIOFB_T *rfb; /*Pointer to the file's feedback structure */
formats buf, in_buf, out_buf; /* Buffers to hold data */
/* Open the device file. */
if (( fp = _Ropen ( "MYLIB/T1677RD2", "ar+" )) == NULL )
{
printf ( "Could not open file\n" );
exit ( 1 );
}
_Rpgmdev ( fp,"DEVICE2" );/* Change the default program device. */
/* Replace with actual device name. */
_Rformat ( fp,"FORMAT2" ); /* Set the record format for the */
/* display file. */
rfb = _Rwrite ( fp, "", 0 ); /* Set up the display. */
rfb = _Rwriterd ( fp, &buf, sizeof(buf) );
rfb = _Rwrread ( fp, &in_buf, sizeof(in_buf), &out_buf,
sizeof(out_buf ));
/* Continue processing. */
_Rclose ( fp );
}