Thread: Subscripting an array

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    49

    Subscripting an array

    I have a question regarding subscripting an array. The problem statement is: "Which of the following cannot be used to subscript an array: Short, Char, Float, or All of the above can be used. My textbook tells me that I should use an integer to subscript an array, or I can use a variable. But the author fails to mention what I cannot use. Can anyone help me out?



    -RedZippo-
    Semper Fi!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    This is an excellent time to write a quick little test program to find out. If you do that you'll quickly learn that an array can only be subscripted by an integral type, that means any of the ints, any of the chars, and any of the longs. The floating-point types aren't allowed.
    My best code is written with the delete key.

  3. #3
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,164
    char, int, long

    Can't use float or double.
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. from 2D array to 1D array
    By cfdprogrammer in forum C Programming
    Replies: 17
    Last Post: 03-24-2009, 10:33 AM
  3. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM