Thread: Array question

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    17
    Rep Power
    0

    Array question


    say I make an array.

    #include<stdio.h>

    static int arr[5];

    /*
    At this point, can I do anything with arr, specificly, put any elements in there? Or is it basically just useless having 5 elements that are just, nothing
    */
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,395
    Rep Power
    1871
    > At this point, can I do anything with arr, specificly, put any elements in there?
    It's an array of 5 ints.
    Store any int you like in arr[0] through to arr[4]


    > Or is it basically just useless having 5 elements that are just, nothing
    Well it's useless until you write some code to use it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo