Passing character data from Fortran to C

Chuck Henkel henkel%nepjt at ncsuvx.ncsu.edu
Sat Jun 22 17:27:18 AEST 1991


I'm trying to write a Fortran wrapper around the C "getenv" routine,
and need to pass character data between Fortran and C. I had in mind
something like this:

character*40 var, value
var = 'USER'//char(0)
call getenval (var, value)
write (*,*) 'Value = ', value
end

With:

#include <stdlib.h>
#include <strings.h>
void getenval (char *ename, char *evalue)
{
  strcpy(evalue,getenv(ename));
  return;
}

But, of course it doesn't work. 

- I tried putting %REF()s around the arguments in the getenval call. 
- Info talks about a builtin version of getenv for fortran, but it
  doesn't have the same functionality as C getenv.

--
| Chuck Henkel                      | There are currently 111 operating      |
| Department of Nuclear Engineering | nuclear power plants in the US,        |
| N.C. State University             | generating nearly 100,000 Megawatts    |
| henkel%nepjt at ncsuvx.ncsu.edu      | of electricity.                        |



More information about the Comp.unix.aix mailing list