Thread: Declaring multiple character variable.

  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,079
    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,218
    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,079
    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, 02: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, 10:54 AM
  4. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM
  5. Declaring multiple functions
    By samuel in forum C++ Programming
    Replies: 1
    Last Post: 10-22-2001, 12:15 AM