- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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).........
:)
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page