Thread: Having major trouble with double arrays using pointers

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    5

    Having major trouble with double arrays using pointers

    Edit, I've resolved my original question, but I've run into a few more.

    I'm trying to create a function that allows me to change a value in my array.

    Also trying to create a function that allows you to specify a min and max value and then returns all values in the range.


    Can someone get me pointed in the right direction?

    If it matters, the values were entered into the array by the user, not defined in the array.
    Last edited by omegasli; 04-09-2011 at 08:46 PM.

  2. #2
    Registered User
    Join Date
    Apr 2011
    Posts
    50
    Code:
    	while (choice == 'y' || choice == 'Y');
        shownumbers(numbers, count);
    	return 0;
    
    }
    try writing it within the main() function.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    gets(numbers) doesn't work the way you want. It lets you enter a string.
    You need to do something like:
    Code:
    int getnumbers(double *numbers) {
    char buffer[100];
    int count = 0;
    double num;
    for (;;) {
        gets(buffer);
        sscanf(buffer, "%lf", &num);
        if (num == 0.0)
            break;
        numbers[count] = num;
        count++;
        }
    return count;
    }
    Note the function now returns the size of the array. You must make use of that.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Posts
    5
    Thank you for your help, but I have resolved the problem while the board was down.

    If you could look at the OP I have a couple more questions that hopefully you can help me out with.

    Feel free to email me if you have some spare time and wouldnt mind helping me understand this all a bit better.

    [email protected]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Again!!
    By Jjoraisnt32 in forum C Programming
    Replies: 7
    Last Post: 02-03-2011, 02:18 PM
  2. Error in printf line,,,what's wrong?
    By mft_ika in forum C Programming
    Replies: 9
    Last Post: 03-19-2010, 08:46 PM
  3. newbie needs help with code
    By compudude86 in forum C Programming
    Replies: 6
    Last Post: 07-23-2006, 08:54 PM
  4. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 06:54 PM
  5. Hi, could someone help me with arrays?
    By goodn in forum C Programming
    Replies: 20
    Last Post: 10-18-2001, 09:48 AM