Thread: Help changing the values inside an array.

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    19

    Help changing the values inside an array.

    Alright, so I have a function where you set up the values for the array. Now I need to find a way to change them. So far it hasn't worked right.

    Code:
    void changegrades(double *grades, int count)
    {
    int i, x;              
                  
    system("cls");              
    printf("Change Grades \n\n");
    
    
    printf("Enter the position of the Grade you want to change (or 0 to quit):");
    scanf("%d%*c", &i);
    i = count;
    if (count == 0)
         { 
         printf("\n\nPress Enter to Continue");
         }
    
    else
        {
        printf("Enter the New Grade: ");
        scanf("%d", &x);
        x = grades[count-1];
        printf("\nNew Grade is %d.", grades[i]);
    
    
    }
    getchar();
    }

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Code:
    scanf("%d%*c", &i);
    i = count;
    Look very closely... what's wrong with that picture.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I think you will not understand CommonTater hint, since you made the same mistake a second time.

    Code:
    int a,b;
    b = 1; /* This changes the value of "b" to 1 */
    a = b; /* This assigns to "a" the value of "b" */
    Tim S.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    50
    x = grades[count-1];
    also correct this, as stahta01 told. if needed read the part of your book related to assignment operator.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. changing array values using pointers
    By dford425 in forum C Programming
    Replies: 8
    Last Post: 01-15-2011, 10:45 PM
  2. Swap values inside of a vector ?
    By Greenhorn__ in forum C++ Programming
    Replies: 5
    Last Post: 09-23-2008, 01:50 PM
  3. Changing pointer inside function?
    By DrSnuggles in forum C++ Programming
    Replies: 2
    Last Post: 07-20-2008, 05:10 AM
  4. changing the prioirty form inside the rt-class?
    By micke_b in forum Linux Programming
    Replies: 0
    Last Post: 02-22-2008, 02:24 PM
  5. Placing values inside stings
    By darfader in forum C Programming
    Replies: 2
    Last Post: 10-15-2003, 05:46 AM