Help with vector program

Apr 20, 2013 at 6:23pm
This is the program I am currently working on, unfortunately my code is not compiling, and I can not figure out what is wrong with it. Someone help, please! I have an exam coming up and must master these topics.

//Write a program that takes in a number of values that should be input, and then that number of inputs from the keyboard. The program should store the numbers in a vector of doubles. After that, your program should read in a find value and a replace value, and then search through the vector, replacing every instance of the find value with the replace value (not including the first number in the vector). The final operation should be printing the new vector.

#include<iostream>
#include<vector>
using namespace std;

double a, nums, find, replace;

int main()
{

cout << "Enter number of values: " << endl;
cin >> a;

cout << "Enter" << a << "values: " << end;
cin << nums;

vector<double> values(a);
values.pushback(nums);

cout << "Enter find value: " << endl;
cin >> find;

cout << "Enter replace value: " << endl;
cout >> replace;

vector<double> values;
int i;
for(i = 0; i < values.size(); i++)
{
if (values.at(i) == find)
{
values.at(i) == replace;
}
}

cout << values << endl;

}
Apr 20, 2013 at 8:20pm
> unfortunately my code is not compiling, and I can not figure out what is wrong with it.
http://www.cplusplus.com/forum/articles/40071/#msg216270

Also, use code tags
Apr 21, 2013 at 6:15am
you should probably read the syntax error...im pretty sure it is because it is push_back() not pushback()
Apr 21, 2013 at 10:04am
You are also declaring the vector values twice.
Topic archived. No new replies allowed.