Thread: Subscripted value is neither array nor pointer nor vector

  1. #1
    Registered User
    Join Date
    Feb 2020
    Posts
    7

    Subscripted value is neither array nor pointer nor vector

    Hi, an error of 'Subscripted value is neither array nor pointer nor vector' has come up when I try to run my 'Hangman' program. It appears in the line:
    if (yourletter[loopIndex]==1){

    I've attached the full program. Any help would be greatly appreciated
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,553
    Well yourletter appears to be a single character not an array.

  3. #3
    Registered User
    Join Date
    Feb 2020
    Posts
    7
    Quote Originally Posted by jimblumberg View Post
    Well yourletter appears to be a single character not an array.
    I have changed it to:
    char yourletter[0];
    But then I get a new error on line 52 ( yourletter=guess[0]; ) saying 'assignment to expression with array type'. What would I do to fix this?

    (btw I am very new to C)

  4. #4
    Registered User
    Join Date
    Aug 2019
    Location
    inside a singularity
    Posts
    309
    Note: I haven't looked at your entire code and am replying just to this message.

    > char yourletter[0];

    This is an array of char of size 0. It's not something you want, do you? Because you can't do anything with it. What you probably want is char yourletter[1];.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 119
    Last Post: 05-26-2019, 12:40 AM
  2. Subscripted value is neither array nor pointer ?
    By prietito1 in forum C Programming
    Replies: 2
    Last Post: 08-08-2012, 12:42 AM
  3. Replies: 1
    Last Post: 05-08-2010, 10:03 PM
  4. Replies: 9
    Last Post: 03-16-2009, 02:18 AM
  5. subscripted value is neither array nor pointer
    By new_to_c in forum C Programming
    Replies: 8
    Last Post: 04-01-2007, 02:43 PM

Tags for this Thread