Click here to Skip to main content
15,850,750 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
what does read statement do in this case?:
int x
read(textpart(2*i-1),'(f20.0)',iostat=istat) x 

textprat is an array of char*
istat is an integer

the first parameter shoudn't be an integer???

anyone could help please?
Sergey Alexandrovich Kryukov 12-Apr-13 11:57am    
I already forget those Fortran trash and mad skills, and I'm too lazy to Google for your, But you are more interested, why wouldn't you do the search? Not the rocker surgery, honestly...

1 solution

You are misusing the read statement. variable 'x' is an integer and the '(f20.0)' is a floating point spec. The results depend on the compiler, but the best answer is that the result is undefined (you might get something useful out of a specific compiler).
Share this answer
nv3 12-Apr-13 12:20pm    
I am impressed! Someone still knows this ancient language :-)
H.Brydon 12-Apr-13 13:02pm    
Ummm... I think that is supposed to be a complement. Thanks I think. :-)
nv3 12-Apr-13 14:55pm    
Absolutely. It sure was.
nouraaa 12-Apr-13 12:21pm    
OK,i didn't write those line, i'm trying to understand it, i need to convert it into c++.
what i can't understand he is trying to read what?? i thought read statement is used to read from standard input or from a file, if he wants to put what's in textpart[2i-1] in x why using read atatement? why not assigning it directly??
H.Brydon 12-Apr-13 13:06pm    
'textpart' is a string. '2*i -1' is an index calculation for where to start within it.
'(f20.0)' is a format spec producing a floating 4 byte value
'iostat=istat' is a spec for return value (variable 'istat')
'x' is an integer where the (floating point) data is returned

The technique is called "memory to memory I/O" (? or some such thing: my memory fails) to allow use of the I/O conversion routines without actually doing any physical I/O.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900