Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

C program on Mainframe

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests
View previous topic :: :: View next topic  
Author Message
sabav42

New User


Joined: 09 Jun 2014
Posts: 5
Location: India

PostPosted: Mon Jun 09, 2014 1:30 pm    Post subject: C program on Mainframe
Reply with quote

Hi All,

I would like to know how to execute C program in Mainframe.
Please help me.

Advance Thanks for your sharing.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7232

PostPosted: Mon Jun 09, 2014 2:34 pm    Post subject: Reply to: C program on Mainframe
Reply with quote

Code:
//stepname EXEC PGM=yourCprogram


If you need something else, first ask how it is done at your site. Is this part of a competition?
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 461
Location: The Universe

PostPosted: Mon Jun 09, 2014 4:54 pm    Post subject:
Reply with quote

You did not tell us whether you really meant, "How do I compile and execute a C program on the mainframe?" or "How do I execute the binary program prepared by compiling a C program?"

Mr. Woodger answered the second question, at least in part. The answer for the first question is more complex. A forum such as this is not a good source for this type of query. It depends on the exact version of the C compiler used on the mainframe you are using and other conventions established for that mainframe. You should ask this question of the support organization for that mainframe.

Another question you did not ask is "How do I specify files for C functions like fopen?"

Going back to the second question in the first paragraph, you did not tell us the environment you expect to use when executing the prgram. There are four possible environments:
  • Batch from JCL
  • TSO command line
  • ISPF
  • The Unix like command environment within TSO
Back to top
View user's profile Send private message
Ed Goodman

Active Member


Joined: 08 Jun 2011
Posts: 556
Location: USA

PostPosted: Mon Jun 09, 2014 5:42 pm    Post subject:
Reply with quote

Man..that sounded like such a simple question when I read it, but these guys are correct. There is much more to it.

Let me tell you how I did it, years ago, under MVS.

You know how you have to compile a COBOL program to make it work? You have to do the same with a C program. In my shop, everyone pretty much uses batch jobs to compile COBOL programs. I poked around and found the libraries where the JCL was stored, then found the C versions of the compilers in that library.

I spent like a week getting the JCL fixed up to point to the needed libraries, have the correct compile options, and produce a usable load module.

Then, I created some execution JCL that needed to have the right system libraries in the STEPLIB.

This was a fun side project for me, and I got to learn about some of the lesser used parts of the shop's mainframe. If I had to do it for real, I would have started by asking my tech support folks where to get the approved compile JCL, or what on-line panel to use to create it.
Back to top
View user's profile Send private message
sabav42

New User


Joined: 09 Jun 2014
Posts: 5
Location: India

PostPosted: Tue Jun 10, 2014 9:17 am    Post subject:
Reply with quote

Yes.. I would like to excute the program in Batch from JCL environment.

As Ed Goodman said, i need to know the library details.
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue Jun 10, 2014 11:31 am    Post subject:
Reply with quote

sabav42 wrote:
As Ed Goodman said, i need to know the library details.
If this is what you are looking forward to then you should be talking to someone at your shop ,no one here can really help you with names at your site.
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 461
Location: The Universe

PostPosted: Tue Jun 10, 2014 10:36 pm    Post subject:
Reply with quote

sabav42 wrote:
Yes.. I would like to excute the program in Batch from JCL environment. ...
OK. Batch JCL.

It's not widely appreciated, but

// EXEC PGM=xxx,PARM='a b c'

is roughly equivalent to using

xxx a b c

in a command line, and a C program can retrieve the text strings in the PARM text just like they would be retrieved from the command line in Windows or *NIX.

Just like any other batch program, you need a //STEPLIB DD statement or a //JOBLIB DD statement to specify the library where the compiled binary program is stored, and any other libraries needed to run your program.

The fopen function will use dynamic allocation if you specify fopen("data set name",...), or fopen will defer to a DD statement if it encounters fopen("dd:dd name",...). The I/O functions like gets and fgets map MVS data sets to Windows or *NIX "flat" files quite well. You can use MVS VSAM files, though I'm not familiar with the details.

This is about as much information as you can get in a public forum like this. For details in your mainframe environment you really need to consult with the support structure for your environment. Good luck.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
This topic is locked: you cannot edit posts or make replies. Urgent Mainframe Requirments (2-10 yr... Shankar779 Mainframe Jobs 0 Sun Nov 27, 2016 1:48 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
This topic is locked: you cannot edit posts or make replies. Mainframe Developer requirement in Ku... capricorn Mainframe Jobs 0 Sun Oct 23, 2016 3:49 pm
No new posts A sample of exit program for exit XMN... lind sh CICS 2 Mon Oct 03, 2016 5:07 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us