Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3021

my build .exe files stopped

$
0
0
My code was running good and passed the compiler.
However, when I tried to run the .exe files from the release, it shows xxxxx.exe files stopped.
I think the problem is in the open the .ini files and read them put them into string array because that it doesn't have any problem before I add those function.

Please help and give me some advice.
Thank you

Code:

#include "stdafx.h"
#include "MySignalHound.h"
#include "math.h"
#include "windows.h"
#include <iostream>
#include <fstream>
#include "windows.h"
#include <sstream>
#include <string>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        CMySignalHound myHound;
        //int centerFreq;
        //int span;
        //int chSp;
        //int rbwPt;

        int ini = myHound.Initialize();
                if(ini!=0)
                {                       

                        MessageBox(NULL,L"USB Connection Error",L"Connection Error!!!", MB_OK|MB_ICONINFORMATION);
                //        cout<< ini;
                //        system("pause");
                //        exit(1);       

                }
                else{
                                                               
                        ifstream setup;
                        setup.open("setup.ini");
                       
                        if(!setup){
                                MessageBox(NULL,L"Can't open setup files",L"Error", MB_OK|MB_ICONINFORMATION);
                       
                        }
                        else
                        {
                                string input[8];
                                int i = 0;
                                while(!setup.eof())
                                {
                                       
                                        getline(setup,input[i]);
                                //        cout<<input[i]<<endl;
                                        i++;                               
                                }
                                setup.close();
                               
                                int centerFreq;
                                int span;
                                int chSp;
                                int rbwPt;
                               
                                stringstream(input[1]) >> centerFreq;
                                stringstream(input[3]) >> span;
                                stringstream(input[5]) >> chSp;
                                stringstream(input[7]) >> rbwPt;
                                centerFreq = centerFreq*10e6;
                                span = span*10e6;
                                rbwPt = rbwPt*10e3;
                                chSp = chSp*10e3;
                        myHound.m_settings.m_RBWIsAuto = true;
                        myHound.m_settings.m_VBWIsAuto = true;
                        myHound.m_settings.m_RBWSetpoint = rbwPt;
                        //myHound.SetStartAndStop(175000000, 185000000);
                        myHound.SetCenterAndSpan(centerFreq,span);
                        //myHound.m_channelBW = 10000;
                        myHound.m_channelSpacing = chSp;
                       
                        int isSetup = myHound.SetupForSweep();
                        int isDoSweep= myHound.DoSweep();
                        int myTraceSize = myHound.m_traceSize;                       
                        double myHzPerPoint = myHound.m_HzPerPt;
                        int peakidx=0;
               
                       
        //Find Peak Idex
                                        for(int i =1; i<myTraceSize;i++)
                                        {       
                                                if(myHound.pDataMax[i]>myHound.pDataMax[peakidx])
                                                peakidx=i;
                                        }
               
                        double peakAmpl = mW2dBm(myHound.pDataMax[peakidx]);
                        double peakFreq = myHound.GetFrequencyFromIdx(peakidx)/10e6;
                       
                        if(peakAmpl<=-50 || peakFreq <=179 || peakFreq>=181)
                                {
                                       
                                        //errorCount++;
                                        std::ofstream log("logfile.csv", std::ios_base::app | std::ios_base::out);
                                        log <<peakAmpl<<" dBm"<< "," <<peakFreq <<" MHz "<<","<<"Error: "<<","<<"******"<<"\n" ;       
                                        printf("Peak Amplitude: %.2f dBm    Peak Freq: %.2f MHz \n",peakAmpl,peakFreq);
                                }
                        else
                                {                       
                                        std::ofstream log("logfile.csv", std::ios_base::app | std::ios_base::out);
                                        log <<peakAmpl<<" dBm"<< "," <<peakFreq <<" MHz "<<"\n" ;       
                                        printf("Peak Amplitude: %.2f dBm    Peak Freq: %.2f MHz \n",peakAmpl,peakFreq);
                                }
                       
                        }
        system("pause");
        return 0;
}
}


Viewing all articles
Browse latest Browse all 3021

Trending Articles