Thread: float m_fis;

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Registered User Ray Schmidt's Avatar
    Join Date
    Feb 2003
    Posts
    17

    I tried

    Not sure why this code is truncating (sorry)

    I tried using what you suggested and just had unexpected results. I'm sure I'm just doing it wrong but how do I get your code to work with this:

    void CRerayDlg::OnMessageButton2()
    {
    if (m_fis == 1) // Set to decimal
    {
    float worka=0;
    float workb=0;
    float workc=0;

    UpdateData(TRUE);
    worka = m_feet/2 + (m_overhang/12);
    workb = (((m_feet/2) + (m_overhang/12))*m_pitch)/12;

    worka = worka*worka;
    workb = workb*workb;
    workc = sqrt(worka+workb);

    m_feet2 = workc;

    m_feet2_c.EnableWindow(TRUE);
    UpdateData(FALSE);
    }

    if (m_fis == 0) // Set to sixteenths
    {

    UpdateData(TRUE);

    const int MAX=7;
    char string[MAX];

    _itoa(m_feet,string,2);

    int six = atoi(string.substr(string.length() - 2, 2).c_str());
    int inch = atoi(string.substr(string.length() - 4, 2).c_str());
    int feet = atoi(string.substr(0, string.length() - 4).c_str());

    double final = (((six / 16.0) + inch) / feet) + feet;
    m_feet2=final;


    MessageBox("Still Working On", "Whatever", MB_ICONEXCLAMATION);
    UpdateData(FALSE);

    }

    }



    C:\My Documents\Programming\Reray\RerayDlg.cpp(252) : error C2228: left of '.substr' must have class/struct/union type
    Last edited by Ray Schmidt; 02-02-2003 at 11:11 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 05-13-2009, 03:25 PM
  2. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  3. Could somebody please help me with this C program
    By brett73 in forum C Programming
    Replies: 6
    Last Post: 11-25-2004, 02:19 AM
  4. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM