- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
All,
My routine is doing a formatted read of a character string from a file to the character variable CFOO and I need to add a NULL character to the end of that character string within CFOO. How is that done?
Thanks in advance,
Jeff
My routine is doing a formatted read of a character string from a file to the character variable CFOO and I need to add a NULL character to the end of that character string within CFOO. How is that done?
Thanks in advance,
Jeff
- Balises:
- Intel® Fortran Compiler
Lien copié
2 Réponses
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
you can generate the NULL character using the function CHAR with zero argument i.e. nullchar=CHAR(0). Add it using the stringconcatenate operator '//' thus
string=TRIM(ADJUSTL(string))//char(0)
ADJUSTL moves the characters in 'string' to the left of the space allotted for the string, removing leading blanks and adding trailing blanks on the right.TRIM chops off all trailing blank characters.You then add theh NULL to the end of the TRImmed result and store the result back into 'string' (or another string). If you know the length of 'string' excluding trailing blanks, you could use
string=string(1:length)//CHAR(0)
This works so long as the space assigned to character string 'string' is at least 1 character longer than 'length'.
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
Thanks!!! That was it!
Jeff
Jeff
Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable