From 4237e6a041bea0b39e4ab20bb05880ee84ca6879 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Sun, 8 Feb 2026 18:20:17 +0000 Subject: [PATCH] add a read after the write --- jcl/TXTWKR01.jcl | 2 +- src/TXTWKR01.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/jcl/TXTWKR01.jcl b/jcl/TXTWKR01.jcl index 0b4b768..1c5c74b 100644 --- a/jcl/TXTWKR01.jcl +++ b/jcl/TXTWKR01.jcl @@ -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 //STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(TXTWKR01)' //GO.TESTDD DD DSN=@05054.DATA(TESTMEM),DISP=SHR, diff --git a/src/TXTWKR01.c b/src/TXTWKR01.c index 51a67e2..5dfc094 100644 --- a/src/TXTWKR01.c +++ b/src/TXTWKR01.c @@ -12,7 +12,7 @@ int main(void) int count = 0; char buf[LINE_LEN]; - /* === Read phase === */ + /* === Read phase before write === */ fp = fopen("dd:TESTDD", "r"); if (fp == NULL) { fputs("Cannot open for read\n", stdout); @@ -42,6 +42,22 @@ int main(void) 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); return 0; } \ No newline at end of file