Re: removing chars from c strings

David: Thanks for the example.

For info, this works under Intel Fortran, ifort V9.x as well, but
with the warning message:

Warning: DFRemoveCh.f90, line 15: A DEC Fortran pointer variable has been explicitly
given a data type that is not the longest integer type associated with the current
platform. [SLOC]
integer :: nc, sloc ; pointer (sloc,a)
27 | The quick brown fox jumps |

Skip Knoble

On Tue, 18 Apr 2006 06:18:04 GMT, "David Frank" <dave_frank@xxxxxxxxxxx> wrote:

-|I posted below in comp.lang.pl1 and thought it might be informative here.
-|=========== begin snip ==============
-|I discovered CVF compiler allows a dynamic pointer connection,
-|and function below uses it to allow pack function to accept a string arg.
-|I dont recall seeing code using this technique before, and will make an
-|in comp.lang.fortran about whether my use shows something not seen before.
-|! -------------------------
-|PROGRAM varying_cstring
-|integer :: n
-|character(100) :: s = ' The qu*ick brown fox ju**mps 'C
-|n = Remove_Ch(s,'*')
-|write (*,*) n,' |',s(1:n),'|'
-|stop ! outputs 27 | The quick brown fox jumps |
-|! ----------------------
-|FUNCTION Remove_Ch(s,ch) RESULT (nc)
-|character(*) :: s
-|character :: ch, a(len(s))
-|integer :: nc, sloc ; pointer (sloc,a)
-|sloc = loc(s) ! dynamic connection a -> s
-|a = pack(a, a/=ch)
-|nc = index(s,char(0)) -1


Relevant Pages

  • Re: Derived Type Pointer Allocation Issue
    ... only way that sizewould be zero is if you previously ... if the pointer is associated with something or not. ... allocate is failing with the following command line ... Next place to go appears to be into the Intel Fortran forums. ...
  • [PATCH 1/5]security:key.c Fix warning: variable key set but not used
    ... building with gcc 4.6 I'm getting a warning message: ... key_ref_t is a typedef'd pointer to a type that is not actually ... In this case the safest approach(in my mind) would be to just ... char __user *buffer, ...
  • Re: Pointer Arguments
    ... with a non-pointer dummy argument provided the pointer is associated. ... there any way for the procedure to do a runtime precondition check on the ... Since you are using Intel Fortran, ... Developer Products Division ...
  • Re: Why compiler not generating any warning ?
    ... You can safely convert a pointer to a structure to a pointer to the first ... pointer arithmetic you perform after the conversion. ... > But on compilation I don't get any warning message. ...
  • warning: passing arg 1 of `atoi makes pointer from integer without a cast
    ... But I get this warning message: ... passing arg 1 of `atoi' makes pointer from integer without a ...