Re: Conversion from int to char



Ron Ford wrote:
On Fri, 29 Aug 2008 14:52:52 -0700 (PDT), e p chandler posted:


Paul van Delst wrote:

michaelmetcalf@xxxxxxxxxxxxxx wrote:

On Aug 29, 4:28 pm, fm2766 <fm2...@xxxxxxxx> wrote:

Hello, I have to convert integers in characters; for example: from
number i=123456 to string c="123456".
I could write in a file the variable "i", and later read it as a
variable "c", but this method seems to me very inefficient.
Some suggestions?

Well, that's almost what you do, however, not to an external file but
to an 'internal' one as defined by your c, as in:

write(c, '(i6)') i

Maybe some thought should be given to giving this process an additional, more intuitive,
name. It's such a common question and "Internal file writing and reading" sure isn't the
first thing a newcomer thinks of when they want to convert int->character or vice versa.

Oh no. Let the C programmers learn some Fortran instead of whining
about it. Learning a foreign language involves learning its idioms. To
a FORTRAN programmer, the concept of "internal file" makes sense.


Gosh, elliot, I know that internal writes have been the answer for a lot of
questions I've had since I renewed my commitment to fortran as a syntax.
It's §9.6 in MR&C.

What I don't see is a file. By "file," do people mean "whatever internal
variables you used to read the data?"
It's an abstract concept...the character variable is a substitute for a "file".

--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • Re: Form k = i + j and test for overflow.
    ... IBM once made a change in VS Fortran that meant you could no longer initialize integers with the max negative 32-bit integer value commonly used to set a specific bit pattern for binary flag values. ... At first they refused to change it back claiming it was fully standard compliant, but after about 6 months of my first complaint, they released an update that put it back the "correct" way. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: When will this ng come to accept that Fortran needs to go "back to the future" ?
    ... I personnally think that that is a silly reason to avoid common blocks. ... Fortran Library: http://www.fortranlib.com ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: taking notes about a code
    ... computer processing unit instruction, you still are writing to the ... FORTRAN or Fortran is a language for communication of mathematical ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Final Procedure
    ... And unless you define some complicated system for such things, ... Fortran Library: http://www.fortranlib.com ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Conversion from int to char
    ... Ron Ford wrote: ... that while they might then be able to find the syntax, ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)