revise C for JCC compatibility
Some checks failed
MVS Delete Members / delete-members (push) Failing after 13s
MVS Submit & Execute / upload-and-run (push) Failing after 51s

This commit is contained in:
Greg Gauthier 2026-02-08 15:43:02 +00:00
parent 68e46fef6b
commit ed41b95105
2 changed files with 12 additions and 39 deletions

View File

@ -1,49 +1,22 @@
#include <stdio.h> #include <stdio.h>
#include <errno.h>
#define BUFFER_SIZE 256
/* Simple program to read and append to a single PDS member via DD name. */
/* Author: Greg Gauthier */
/* Date: 2026-02-08 */
/* NOTE: No single-line comments due to MVS SYSIN/JCL interpretation. */
int main() int main()
{ {
FILE *fp_read; FILE *fp;
FILE *fp_append; char buf[256];
char buffer[BUFFER_SIZE];
/* First: open for reading only to dump current content */ fp = fopen("dd:TESTDD", "r");
fp_read = fopen("dd:TESTDD", "r"); if (fp == NULL) {
if (fp_read == NULL) printf((char *)"fopen read failed\n");
{
perror("fopen read failed");
printf("errno = %d\n", __errno());
return 1; return 1;
} }
printf("Existing content:\n"); printf((char *)"Existing content:\n");
while (fgets(buffer, BUFFER_SIZE, fp_read) != NULL) while (fgets(buf, 256, fp) != NULL) {
{ printf((char *)"%s", buf);
printf("%s", buffer);
} }
fclose(fp_read); fclose(fp);
/* Second: open for append only to add the new line */
fp_append = fopen("dd:TESTDD", "a");
if (fp_append == NULL)
{
perror("fopen append failed");
printf("errno = %d\n", __errno());
return 1;
}
fprintf(fp_append, "Appended from C program!\n");
fclose(fp_append);
printf("Append complete.\n");
printf((char *)"Read complete.\n");
return 0; return 0;
} }