nuclearfroggy's Profile User Rating: -----

Reputation: 82 Whiz
Group:
Contributors
Active Posts:
167 (0.08 per day)
Joined:
04-August 08
Profile Views:
5,337
Last Active:
User is offline Jul 07 2014 02:38 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
50

Latest Visitors

Icon   nuclearfroggy has not set their status

Posts I've Made

  1. In Topic: Basic Arrays: Average, Stddev, Bubblesort

    Posted 17 Oct 2012

    Okay, this is because when you say x[i] you're saying the ith element of the array x. You're then passing this to average(), but average() doesn't want an integer, it wants an array of integers. What you meant was:
     double avg = average(x, SIZE); 
    

    By just using the array name you pass a pointer to the first element in the array. You should also check out some tutorials on pointers and arrays while you're at it. :)
  2. In Topic: READING .CSV TO 2D VECTOR

    Posted 17 Oct 2012

    You aren't calling getline correctly. The first argument should be an input stream ie istream or ifstream, not ostream or ofstream. So it should be ifstream myFile. Next, you need to specify a string to store the read in input in. You should specify a string to store the temporary read in data. With the third argument you've said the delimiter should be the comma character. Check here for how to use getline.

    I'm not entirely sure what you're trying to do with line 34, that syntax isn't right though. You're trying to assign a string to a float value, and the constructor for string doesn't look right.

    Sorry I can't help any more, could you give us an example a file that you'd read in?
  3. In Topic: Basic Arrays: Average, Stddev, Bubblesort

    Posted 17 Oct 2012

    Your problem is coming from a bit of a misconception. In short, the error says that you're trying to return a function pointer when it expected a double. This might be a bit beyond what you've done, but the important bit is the fact you've declared your function "double average" doesn't mean you've got a double variable called "average". You've got a function (called "average") that returns a double value.

    The simple fix is to create a variable to store the value and return that. For example, for the average function this should work:
    //average
    double average(int x[], int SIZE)
    {
      double avg, total = 0.0;
      int i;
      
      for (i=0; i < SIZE; i++)
      {
        total += x[i];
      }
      avg = total / (SIZE-1);
      
      return avg;
    }
    

    Hope you've seen where you went wrong, if you need any clarification please say!

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Interests:
Rock Climbing, Tennis
Programming Languages:
C++

Contact Information

E-mail:
Private
Website URL:
Website URL  http://programmingnotesblog.blogspot.com/

Friends

Comments

nuclearfroggy has no profile comments yet. Why not say hello?