Thread: Arrays

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    3

    Arrays

    Hi all,

    I was wondering if this is possible? I am wanting to build an array. I am wanting to use scanf for the user to input integers until he/she chooses to end. In other words the array could be various sizes and everything I have read, states that you need to define the array size before hand. So I am just wondering if this is possible?

    Thanks.

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    So you want an array that is of indefinite size? You will have to allocate memory as you go, using malloc to allocate more memory for more user input as you go along,

  3. #3
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    Or just use a linked list.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Or rather, have to use realloc, since the array must grow in such case.
    A linked list is not an array, though.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function to read in two arrays
    By ssmokincamaro in forum C Programming
    Replies: 7
    Last Post: 11-12-2008, 07:59 AM
  2. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  3. Replies: 16
    Last Post: 01-01-2008, 04:07 PM
  4. Need Help With 3 Parallel Arrays Selction Sort
    By slickwilly440 in forum C++ Programming
    Replies: 4
    Last Post: 11-19-2005, 10:47 PM
  5. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM