- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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
링크가 복사됨
2 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
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'.