Re: C Novice

2009-03-07 Thread Sasha
Why not trying simple //OUTF DD SYSOUT=* ... That should go to SYSPRINT.

On Fri, Mar 6, 2009 at 9:29 PM, Lorne Dudley  wrote:

> I'm a novice trying to get a simple C program running under MVS.
>
> I'm attempting to get file output to
> //OUTF DD SYSOUT=A
> with the following program.
>
> #include 
> int main(void)
> {
>  FILE *outf = NULL;
>  printf("TESTFILE has been entered.\n");
>  outf = fopen("dd:OUTF","recfm=fba, w+");
>  if (!outf)
>{
>printf("fopen error on FILE *outf.\n");
>return 4;
>}
>  fprintf(outf, "outf open ...\n");
>  fclose(outf);
>  return 0;
> }
>
> So far, with many variations to the fopen string, I get only the following
> output on SYSPRINT, no output to OUTF.
>
> TESTFILE has been entered.
> fopen error on FILE *outf.
>
> Can anyone give me some advice on how to code this correctly ?
>
> Regards
>
> Lorne Dudley
> Queen's University
> Kingston, Ontario
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
> Search the archives at http://bama.ua.edu/archives/ibm-main.html
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-07 Thread Bernd Oppolzer
I would suggest to avoid the MVS specific open mode strings
(that is, recfm, lrecl and so on) as often as possible, because, 
if you use the simple "w" and "r" strings, the program will 
probably run on every platform, which is not so in the other case. 

My experience is that you don't need those MVS extensions most
of the time. One example where they are indeed needed is: if 
you try to write a binary file with variable length (a VB file
with binary contents, not only text). 

If you ever have questions about C on MVS, you could ask me offline
(15 years experience here). 

Kind regards

Bernd



Am Samstag, 7. März 2009 06:35 schrieben Sie:
> Hi Bill !
>
> Thanks for all your assistance.
>
> outf = fopen("dd:OUTF","w");
> works for both the pre-assigned disk file and the SYSOUT=A .
>
> Regards
>
> Lorne
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Lorne Dudley

Hi Bill !

Thanks for all your assistance.

outf = fopen("dd:OUTF","w");
works for both the pre-assigned disk file and the SYSOUT=A .

Regards

Lorne

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Bill Godfrey
In the 2nd argument of fopen, the keyword parameters come after the mode. 
Try it with just "w" or "w, recfm=fba".

Bill

On Fri, 6 Mar 2009 23:21:41 -0500, Lorne Dudley wrote:

>Hi Bill (or any other C programmer) !
>
>OK, perror("dd:OUTF"); gives me
>
>EDC5057I The open mode string was invalid. Explanation: The mode string
>passed to the fopen()/freopen() function was found to have invalid
>keywords, combinations, or characters. For example, if you are opening a
>ddname, be sure the DISP= specified on the DD statement is compatible
>with the open mode you specified. Programmer response: Correct the mode
>string and reissue the fopen()/freopen().
>
>I'm not much wiser with this explanation.
>
>I know that if I use only
>outf = fopen("dd:OUTF","w+");
>and
>//OUTF DD DISP=OLD,DSN=SYS2#.C.OUTF
>
>the program executes properly with zero return code.
>In this case the OUTF file is on disk with recfm=vb, lrecl=1028,
>blksize=6144.
>
>So I'm still in the dark as to how to get this to write to SYSOUT=A.
>
>Regards
>
>Lorne
>
>On Fri, 6 Mar 2009 21:29:17 -0500, Lorne Dudley wrote:
>
> > >I'm a novice trying to get a simple C program running under MVS.
> > >
> > >I'm attempting to get file output to
> > >//OUTF DD SYSOUT=A
> > >with the following program.
> > >
> > >#include 
> > >int main(void)
> > >{
> > >   FILE *outf = NULL;
> > >   printf("TESTFILE has been entered.\n");
> > >   outf = fopen("dd:OUTF","recfm=fba, w+");
> > >   if (!outf)
> > > {
>
>perror("dd:OUTF");
>
> > > printf("fopen error on FILE *outf.\n");
> > > return 4;
> > > }
> > >   fprintf(outf, "outf open ...\n");
> > >   fclose(outf);
> > >   return 0;
> > >}
> > >
> > >So far, with many variations to the fopen string, I get only the
> > >following output on SYSPRINT, no output to OUTF.
> > >
> > >TESTFILE has been entered.
> > >fopen error on FILE *outf.
> > >
> > >Can anyone give me some advice on how to code this correctly ?
> > >
>
>The "perror" function might give you more information about why fopen is
>failing. See above.
>
>Bill
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Lorne Dudley

Hi Bill !

Through trial and error and the use of perror("dd:OUTF"); I have 
determined that this syntax works as expected.


outf = fopen("dd:OUTF", "w");

Thanks for the lead.

Regards

Lorne


Bill Godfrey wrote:

On Fri, 6 Mar 2009 21:29:17 -0500, Lorne Dudley wrote:


I'm a novice trying to get a simple C program running under MVS.

I'm attempting to get file output to
//OUTF DD SYSOUT=A
with the following program.

#include 
int main(void)
{
  FILE *outf = NULL;
  printf("TESTFILE has been entered.\n");
  outf = fopen("dd:OUTF","recfm=fba, w+");
  if (!outf)
{


   perror("dd:OUTF");


printf("fopen error on FILE *outf.\n");
return 4;
}
  fprintf(outf, "outf open ...\n");
  fclose(outf);
  return 0;
}

So far, with many variations to the fopen string, I get only the
following output on SYSPRINT, no output to OUTF.

TESTFILE has been entered.
fopen error on FILE *outf.

Can anyone give me some advice on how to code this correctly ?



The "perror" function might give you more information about why fopen is 
failing. See above.


Bill




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Lorne Dudley

Hi Bill (or any other C programmer) !

OK, perror("dd:OUTF"); gives me

EDC5057I The open mode string was invalid. Explanation: The mode string 
passed to the fopen()/freopen() function was found to have invalid 
keywords, combinations, or characters. For example, if you are opening a 
ddname, be sure the DISP= specified on the DD statement is compatible 
with the open mode you specified. Programmer response: Correct the mode 
string and reissue the fopen()/freopen().


I'm not much wiser with this explanation.

I know that if I use only
outf = fopen("dd:OUTF","w+");
and
//OUTF DD DISP=OLD,DSN=SYS2#.C.OUTF

the program executes properly with zero return code.
In this case the OUTF file is on disk with recfm=vb, lrecl=1028, 
blksize=6144.


So I'm still in the dark as to how to get this to write to SYSOUT=A.

Regards

Lorne

On Fri, 6 Mar 2009 21:29:17 -0500, Lorne Dudley wrote:

> >I'm a novice trying to get a simple C program running under MVS.
> >
> >I'm attempting to get file output to
> >//OUTF DD SYSOUT=A
> >with the following program.
> >
> >#include 
> >int main(void)
> >{
> >   FILE *outf = NULL;
> >   printf("TESTFILE has been entered.\n");
> >   outf = fopen("dd:OUTF","recfm=fba, w+");
> >   if (!outf)
> > {

   perror("dd:OUTF");

> > printf("fopen error on FILE *outf.\n");
> > return 4;
> > }
> >   fprintf(outf, "outf open ...\n");
> >   fclose(outf);
> >   return 0;
> >}
> >
> >So far, with many variations to the fopen string, I get only the
> >following output on SYSPRINT, no output to OUTF.
> >
> >TESTFILE has been entered.
> >fopen error on FILE *outf.
> >
> >Can anyone give me some advice on how to code this correctly ?
> >

The "perror" function might give you more information about why fopen is
failing. See above.

Bill

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Lorne Dudley

Thanks for the hint Bill.

That gives me
dd:OUTF: EDC5057I The open mode string was invalid. (errno2=0xC00B0022)

I'll chase that mesage and see what I can decipher.

Regards

Lorne

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html


Re: C Novice

2009-03-06 Thread Bill Godfrey
On Fri, 6 Mar 2009 21:29:17 -0500, Lorne Dudley wrote:

>I'm a novice trying to get a simple C program running under MVS.
>
>I'm attempting to get file output to
>//OUTF DD SYSOUT=A
>with the following program.
>
>#include 
>int main(void)
>{
>   FILE *outf = NULL;
>   printf("TESTFILE has been entered.\n");
>   outf = fopen("dd:OUTF","recfm=fba, w+");
>   if (!outf)
> {

   perror("dd:OUTF");

> printf("fopen error on FILE *outf.\n");
> return 4;
> }
>   fprintf(outf, "outf open ...\n");
>   fclose(outf);
>   return 0;
>}
>
>So far, with many variations to the fopen string, I get only the
>following output on SYSPRINT, no output to OUTF.
>
>TESTFILE has been entered.
>fopen error on FILE *outf.
>
>Can anyone give me some advice on how to code this correctly ?
>

The "perror" function might give you more information about why fopen is 
failing. See above.

Bill

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@bama.ua.edu with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html