Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Hollerith constants

jinnu_us
Beginner
359 Views
I am facing a problem while porting from fortran to 'C'.
Hollerith constants with characters are compared with integers. How do I do this in 'C'?
ex:
INTEGER CHEK
DATA JINNU/4HBLUE/,BLNK/4H /
.
.
.
IF(CHEK .NE. JINNU).........
:)
0 Kudos
1 Reply
TimP
Honored Contributor III
359 Views
This style of string constant is obsolete in Fortran since 1978, and in C at least since 1989. You could do the similar thing in K&R C, e.g.
static int JINNU[2]={'BLUE','BLNK'}
assuming that your C int is the same size as your Fortran INTEGER,
but it is even less portable in C than in Fortran. For example, you will run into byte order problems in comparing with string constants.
So, do the obvious thing and use standard Fortran CHARACTER and C string constants. You will need strncmp() or the like in C.
0 Kudos
Reply