Thread: Error C2109: subscript requires array or pointer type

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    9

    Question Error C2109: subscript requires array or pointer type

    I am very new to C programming so this may be a silly question. I am recieving the following error and don't know why:

    error C2109: subscript requires array or pointer type

    The code that it is pointing to are these three lines:

    tempFahr = fahr[indexOfMinFahr];
    fahr[indexOfMinFahr] = fahr[fillFahr];
    fahr[fillFahr] = tempFahr;

    Any suggestions? Thanks

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Is fahr an array? Can we see the declaration?

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    the error message is composed of quite clearly-spoken english. in order to use subscrpiting, you must be operating on an array or a pointer. fahr is neither of these.
    hello, internet!

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    9
    Here are the declarations:

    double fahr[20];
    double tempFahr;
    double indexOfMinFahr;
    double fillFahr;

  5. #5
    Registered User moi's Avatar
    Join Date
    Jul 2002
    Posts
    946
    Originally posted by Rafiki
    Here are the declarations:

    double fahr[20];
    double tempFahr;
    double indexOfMinFahr;
    double fillFahr;
    the index of the subscript has to be of an integral type
    hello, internet!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting the matrix question..
    By transgalactic2 in forum C Programming
    Replies: 47
    Last Post: 12-22-2008, 03:17 PM
  2. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  5. "subscript requires array or pointer type"?
    By Nutka in forum C Programming
    Replies: 12
    Last Post: 12-06-2002, 05:51 PM