- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create a pair of 5-char strings, str1 and str2. Assign the first with str1='' and leave str2 alone. Then assign "mw2" to them both, character-by-character. Positions 4:5 of str1 will contain space characters (ichar=32); str2 will contain nulls (ichar=0). When placed in a test for equality by .EQ. or CASE SELECT, str1 will match a string "mw2" in the test; str2 won't. str1 will return LEN_TRIM=3; str2 will return LEN_TRIM=5. This behavior seems inconsistent. Shouldn't null (0) and space (32) behave the same way? Any comments would be welcome.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Two comments:
Initialize all variables before using. (don't just 'leave str2 alone')
There are cases where null (0) and space (32) don't behave the same way (mixed language programming for one)
hth,
John
hth,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In Fortran, NUL is just another non-printing character and is not treated the same as a space.
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