Declaring multiple character variable.

This is a discussion on Declaring multiple character variable. within the C Programming forums, part of the General Programming Boards category; I need to convert a certain fortran program in C. The fortran has a statement as follows: implicit real*8 (a-h,o-z) ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    11

    Declaring multiple character variable.

    I need to convert a certain fortran program in C.
    The fortran has a statement as follows:
    implicit real*8 (a-h,o-z)
    In the above statement a series of character variable a-h and o-z is declared in one single statement. (i.e. a, b, c ...h) and so on.
    I want to know if C has any equivalent statement that would enable me to declare multiple variable in one single statement.
    Thanks

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    a-h are variable identifiers or the values of the variables?

    The best you could do is an array.
    Code:
    char arry[26];
    or if you want, you could just use commas
    Code:
    char a, b, c, d, e, f, g, h, o, p, q, r, s, t, u, v, w, x, y, z;
    That's a single statement.
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    11
    Quote Originally Posted by SlyMaelstrom
    a-h are variable identifiers or the values of the variables?

    The best you could do is an array.
    Code:
    char arry[26];
    or if you want, you could just use commas
    Code:
    char a, b, c, d, e, f, g, h, o, p, q, r, s, t, u, v, w, x, y, z;
    That's a single statement.
    a-h are actually variable identifiers. I know declaring
    char a,b,c,d,e,f.....;
    but shouldn't there be a short cut, i mean think of it just a-h

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    11
    Quote Originally Posted by rajabadsha
    a-h are actually variable identifiers. I know declaring
    char a,b,c,d,e,f.....;
    but shouldn't there be a short cut, i mean think of it just a-h
    Sorry I meant
    int a, b, c, d, e....

  5. #5
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,159
    Quote Originally Posted by rajabadsha
    but shouldn't there be a short cut, i mean think of it just a-h
    Why? I can't think of any circumstance in which I ever needed that many non-descriptive, distinct variables in C. What would they be used for?

    If I saw a program that used that many non-descript variables in one scope I'd immediately suspect a need for redesign.
    Last edited by itsme86; 05-12-2006 at 11:29 AM.
    If you understand what you're doing, you're not learning anything.

  6. #6
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Seriously, I would say that shortcut is probably one of the worst features I've ever seen about FORTRAN. How could the possibly be so implicit. There isn't a single programmer that doesn't know FORTRAN that would take "a-h" as creating variables with the names from a to h.
    Sent from my iPadŽ

  7. #7
    Sys.os_type="Unix";;
    Join Date
    Aug 2005
    Posts
    52
    Quote Originally Posted by SlyMaelstrom
    Seriously, I would say that shortcut is probably one of the worst features I've ever seen about FORTRAN. How could the possibly be so implicit. There isn't a single programmer that doesn't know FORTRAN that would take "a-h" as creating variables with the names from a to h.

    When I see 'a-h' I think of pattern matching immediately

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. about wide character and multiple byte character
    By George2 in forum C Programming
    Replies: 3
    Last Post: 05-22-2006, 08:11 PM
  2. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  3. Edit a character string with an assigned variable
    By jeffdavis_99 in forum C++ Programming
    Replies: 2
    Last Post: 03-25-2005, 09:54 AM
  4. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 01:26 PM
  5. Declaring multiple functions
    By samuel in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2001, 12:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21