- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Question about proper way to pad a charactersubstring with blanks:
character(5) str
str(1:5) = '12345'
does assigning a single blank ' ' as follow cause position 3 tru5 to be padded with blanks also?
str(2:) = ' ' ! str = '1bbbb' where b stands for blank
Itworks, but just wanted to be sure that this is the proper way tooverwrite existing characters with blanks.
or is this better,
str = str(1:1) ! str = '1bbbb'
Thanks fora reply.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Fortran language defines character assignment to do padding on the right with blanks as needed, so your str(2:) = '' is just fine. You may want to look at the standard intrinsics ADJUSTL and ADJUSTR to see if they are of interest for your application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you.
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