add a read after the write
This commit is contained in:
parent
ef09918b95
commit
4237e6a041
@ -1,4 +1,4 @@
|
|||||||
//TXTWKR01 JOB (GCC),'File I/O Test',NOTIFY=@05054,CLASS=A,MSGCLASS=H,
|
//TXTWKR01 JOB (GCC),'File I/O Test',NOTIFY=@05054,CLASS=A,MSGCLASS=A,
|
||||||
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
||||||
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(TXTWKR01)'
|
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(TXTWKR01)'
|
||||||
//GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR,
|
//GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR,
|
||||||
|
|||||||
@ -12,7 +12,7 @@ int main(void)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
char buf[LINE_LEN];
|
char buf[LINE_LEN];
|
||||||
|
|
||||||
/* === Read phase === */
|
/* === Read phase before write === */
|
||||||
fp = fopen("dd:TESTDD", "r");
|
fp = fopen("dd:TESTDD", "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fputs("Cannot open for read\n", stdout);
|
fputs("Cannot open for read\n", stdout);
|
||||||
@ -42,6 +42,22 @@ int main(void)
|
|||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
|
/* === Read phase after write === */
|
||||||
|
fp = fopen("dd:TESTDD", "r");
|
||||||
|
if (fp == NULL) {
|
||||||
|
fputs("Cannot open for read\n", stdout);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fputs("Existing content:\n", stdout);
|
||||||
|
while (fgets(buf, LINE_LEN, fp) && count < MAX_LINES) {
|
||||||
|
fputs(buf, stdout); /* echo to JES */
|
||||||
|
strncpy(lines[count], buf, LINE_LEN-1);
|
||||||
|
lines[count][LINE_LEN-1] = '\0';
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
fputs("Append complete (via rewrite).\n", stdout);
|
fputs("Append complete (via rewrite).\n", stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user