Thread: arrays

  1. #1
    Unregistered
    Guest

    arrays

    what is the code to add a new item to the array

    i did like that
    int Num[current_item];
    int new_item;
    Num[current_item]=new_item;
    current_item=current_item+1;
    cout<<"the number you added is:"<<new_item<<endl;

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    What do you mean with adding a new item to the array? Something like this:

    Code:
    int array [ARRAY_SIZE];
    int index;
    
    for (index = 0; index < ARRAY_SIZE; index++)
    {
        // add item to array
        array [index] = index;
    
        cout << "Added number = " << array [index] << endl;
    }

  3. #3
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    if all the data types match then this should work fine....


    matheo917

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