it is my first time using C PRO(array) help!

This is a discussion on it is my first time using C PRO(array) help! within the C Programming forums, part of the General Programming Boards category; i have a array statement, Code: #define ARRLENG 8 #define myArr 8 int grades[myArr]={1,12,23,0,-1,-12,-23,289}; int i,j; printf("The data in myAr ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    2

    it is my first time using C PRO(array) help!

    i have a array statement,

    Code:
    #define ARRLENG 8
        #define myArr 8
        int grades[myArr]={1,12,23,0,-1,-12,-23,289};
        int i,j;
        
        printf("The data in myAr are: \n");
        for(i=0; i<ARRLENG; i++)
        {
            printf("%d ",grades[i]);
    
        }
    new i let user to input 8 new integers! how can do that 8 integers for array myArr can be changed by user

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    613
    You basically have the code down, You can use the for loop like you have above, except instead of printing the values you can scan them in.

    EDIT: I might have understood your question wrong, but if you are asking if the user can make the array bigger? Then the answer is no, not with your statically allocated array. You could possibly make your array larger if you used a dynamic allocation approach and then copied over the original array to the new larger one.
    Last edited by camel-man; 11-29-2012 at 08:40 PM.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    2
    Quote Originally Posted by camel-man View Post
    You basically have the code down, You can use the for loop like you have above, except instead of printing the values you can scan them in.

    EDIT: I might have understood your question wrong, but if you are asking if the user can make the array bigger? Then the answer is no, not with your statically allocated array. You could possibly make your array larger if you used a dynamic allocation approach and then copied over the original array to the new larger one.
    thanks you
    i have done this part by using the loop function.using loop function for requesting user to input the integer and show these numbers by using the loop function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. qsot array of Time objects - help
    By plaster in forum C++ Programming
    Replies: 7
    Last Post: 03-05-2012, 01:28 PM
  2. Moving through an array one step at a time
    By matinthehat in forum C++ Programming
    Replies: 4
    Last Post: 04-24-2011, 02:31 PM
  3. Static, Stack, Heap Array and time
    By 26friends26 in forum C++ Programming
    Replies: 3
    Last Post: 02-15-2011, 03:42 PM
  4. Array size at run time unknown
    By lechat in forum C++ Programming
    Replies: 4
    Last Post: 11-15-2007, 11:25 AM
  5. Run-time error allocating 3-D array
    By OceanDesigner in forum C++ Programming
    Replies: 2
    Last Post: 10-22-2005, 02:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21