CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • SQL Server Modeling Services with Microsoft Visual Studio 2010 Beta 2
  • Faltering Windows support
  • Internet Explorer 8 Click Clever Click Safe
  • Release Candidate 2 for ASP.NET MVC 2

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    C++ (Non Visual C++ Issues) Ask or answer C and C++ questions not related to Visual C++. This includes Console programming, Linux programming, or general ANSI C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old November 9th, 2009, 04:03 PM
    newbie_to_C newbie_to_C is offline
    Junior Member
     
    Join Date: Nov 2009
    Posts: 1
    newbie_to_C is an unknown quantity at this point (<10)
    Help needed with conversion to string

    Hi everyone,
    I dint not post the complete program, just the most relevant parts. I think the problem is with conversion part towards the end . I cant print the correct values to the text or edit box on the GUI, it prints out some weird values. Thanks in advance for the help. The value "ADD" is like "5.641087567e-007".



    CODE:



    chemicalname = (Edit3->Text);

    if (chemicalname == "7440-38-2")
    {
    ChemRfDwater = 0.0003;
    this->Edit8->Text = FloatToStr(ChemRfDwater);
    }
    else if (chemicalname == "7440-43-9")
    {
    ChemRfDwater = 0.0005;
    this->Edit8->Text = FloatToStr(ChemRfDwater);
    }
    else if (chemicalname == "7440-02-0")
    {
    ChemRfDwater = 0.02;
    this->Edit8->Text = FloatToStr(ChemRfDwater);
    }
    else if (chemicalname == "7783-79-1")
    {
    ChemRfDwater = 0.005;
    this->Edit8->Text = FloatToStr(ChemRfDwater);
    }
    else if (chemicalname == "7440-66-6")
    {
    ChemRfDwater = 0.3;
    this->Edit8->Text = FloatToStr(ChemRfDwater);
    }

    FILE *SourceFile = fopen ("c:\\temp\\test.grf","r");
    if (SourceFile != NULL)
    {
    while(fgets(sizeLineInput, 10000, SourceFile)!=NULL)
    {
    token = strstr(sizeLineInput ,"IngWater_HumRcp");
    if (token)
    {
    fgets(sizeLineInput, 10000, SourceFile);
    while((c=fgetc(SourceFile))!='\r')
    {
    if(c==',')
    {
    num[idx]=0;
    n++;
    array[n] = atof(num);
    idx=0;
    }
    else
    {
    num[idx] = c;
    idx++;
    }
    break;
    }
    }
    }
    for (int i=1;i<n+1;i++)
    {
    if (array[i]>largest)
    {
    largest=array[i];
    }
    }
    ADD = largest;
    HazardQuotient = (ADD/ChemRfDwater);
    if (token == NULL)
    {
    Application->MessageBox("Refer to the messages for details.\n It could be one of the several reasons, namely:\n 1. Mass does not reach water-table. \n 2. Mass does not reach well. \n 3. Well is not in the direction of the aquifer.", "Message", MB_OK + MB_DEFBUTTON1);
    }
    }
    Reply With Quote
      #2    
    Old November 9th, 2009, 04:18 PM
    MrViggy's Avatar
    MrViggy MrViggy is offline
    Elite Member
     
    Join Date: Feb 2002
    Posts: 3,832
    MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+) MrViggy has much to be proud of (1500+)
    Re: Help needed with conversion to string

    Please use code tags to format your code. Also, do you have a complete program? What is 'chemicalname'? What is 'ChemRfDwater'?

    Viggy
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > C++ (Non Visual C++ Issues)


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:00 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.