- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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 kopiert
1 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
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.

Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite