Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

c++ problem i cant iron out

Options
  • 20-12-2005 8:31pm
    #1
    Closed Accounts Posts: 49


    im writting a small program and i keep getting this error:

    error C2111: pointer addition requires integral operand.

    anyone got any ideas as to the problem?

    heres the whole program:



    #include <iostream.h>
    #include <conio.h>
    #include <string>
    #include <vector>

    using namespace std;

    main()
    {
    float qty, i, lastqty(0),proqty(0) ;
    float width,lenght, panelw(0), panell(0),result(0), wholeframe(0), promeasure(0);
    vector<float> list;
    cout<<"Qty: ";
    cin>>qty;
    cout<<"Width: ";
    cin>>width;
    cout<<"Length: ";
    cin>>lenght;

    while (list.size() >= 0){
    if(qty > 0){
    result = width - 4.25;
    panelw=result;
    panell=lenght-4.25;
    proqty=proqty+qty;
    wholeframe=result+lenght;
    promeasure=promeasure+wholeframe;

    list.push_back(qty + " " + width + " X " + lenght + " " + result + " " + panelw + " X " + panell);


    cout<<"Qty: ";
    cin>>qty;
    cout<<"Width: ";
    cin>>width;
    cout<<"Length: ";
    cin>>lenght;

    }
    i=0;
    while (i < list.size()){
    cout<<list<<endl;
    i++;
    }

    }

    }


Comments

  • Registered Users Posts: 6,494 ✭✭✭daymobrew


    list.push_back(qty + " " + width + " X " + lenght + " " + result + " " + panelw + " X " + panell);
    
    What are you trying to do here? list is of type float but by putting the spaces it looks like you are trying to create a string.
    I tried changing the list type to 'char *' and using sprintf to create a string to push_back but it caused a run time (Access Violation) error for me. I guess that there is a correct way to achieve this.


  • Closed Accounts Posts: 49 boyracer87


    im trying to put
    "(qty + " " + width + " X " + lenght + " " + result + " " + panelw + " X " + panell);" into the vector<float> so i can cout them as a list.

    for example:
    QTY Width lenght result panelw panell
    2 23 X 45 18.75 18.75 X 40

    do you think it would be easyer to use an array?

    by the way, just in case your wondering, the program is for caculating certain measurments of doors.


Advertisement