thanks but the format needs to use linked list, and the polynomial is entered all at once. so i need to figure out how to separate the each term. im trying to use cin.ignore but am confused.

thanks! i see what you're saying but i pretty much just want for this example polynomial +3x^6 +2x^2 +9x^0:

store c = +3... ignore x and ^... store 2... store c and e in linked list
ignore space
store c = +2... ignore x and ^... store 2... store c and e in linked list
ignore space
store c = +9... ignore x and ^... store 0... store c and e in linked list

the ignore function is confusing me at the moment.

You don't need to use the ignore function, you can just do something like this :

const int SPACE = ' ';
//peek the next character to see if its a space, if so then discard it
if(cin.peek() == SPACE) cin.get(); //opt #1
char ch = 0;
cin.get(ch); //Opt # 2
if(ch != SPACE){ /*do something */ }
//opt #3
string term;
cin >> term; //read in a term and skip white spaces
prase(term);
//Hint on opt # 4
stringstream ss("3x^6 + 2x^2 + 9");
string str;
while(ss >> str){
cout << str << endl; //prints each term
}

This prompts you to type in the polynomial then it finds and replaces all "x^" with a " ". Then it loads the modified string into a stringstream and then populates the vector of monomials.

#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
struct monomial
{
int coeff;
int exp;
};
int main()
{
stringstream ss;
int numTerms = 0;
string input = "";
cout << "How many terms will the polynomial have?" << endl;
cin >> numTerms;
cin.ignore();
vector<monomial> polynomial(numTerms);
cout << "Enter the polynomial: ";
getline(cin, input);
for( unsigned int i = 0; i < input.size(); i++ )
if( input.substr(i, 2) == "x^" )
input.replace(i, 2, " "); //replace all x^ with a space
ss << input; //add input to the stream
for( unsigned int i = 0; ss >> polynomial[i].coeff; i++ ) //while there is still information to be read from the stream
ss >> polynomial[i].exp;
for( unsigned int i = 0; i < polynomial.size(); i++ ) //output
{
cout << polynomial[i].coeff << "x^" << polynomial[i].exp;
if( i != polynomial.size()-1 )
cout << " + ";
else
cout << endl;
}
cout << endl;
return 0;
}

First of, i didn't know where to post this question as it isn't actually programming based but yeah. sorry.. Anyway, I was going through my binary file trying to figure ...