Click here to Skip to main content
15,906,574 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Calling Unmanaged Class From DLL Pin
Hristo-Bojilov5-Sep-09 7:55
Hristo-Bojilov5-Sep-09 7:55 
GeneralRe: Calling Unmanaged Class From DLL Pin
Joe Woodbury5-Sep-09 8:48
professionalJoe Woodbury5-Sep-09 8:48 
AnswerRe: Calling Unmanaged Class From DLL Pin
Joe Woodbury5-Sep-09 8:55
professionalJoe Woodbury5-Sep-09 8:55 
GeneralRe: Calling Unmanaged Class From DLL Pin
İsmail Durmaz6-Sep-09 3:12
İsmail Durmaz6-Sep-09 3:12 
GeneralRe: Calling Unmanaged Class From DLL Pin
Joe Woodbury6-Sep-09 7:36
professionalJoe Woodbury6-Sep-09 7:36 
QuestionSTL map in UNIX Pin
ashukasama4-Sep-09 23:24
ashukasama4-Sep-09 23:24 
AnswerRe: STL map in UNIX Pin
Richard MacCutchan4-Sep-09 23:36
mveRichard MacCutchan4-Sep-09 23:36 
GeneralRe: STL map in UNIX Pin
ashukasama4-Sep-09 23:53
ashukasama4-Sep-09 23:53 
Above code is working, But this code is not working

//Inclue files for libraries
#include <stdlib.h>
#include <ctype.h>
#include <iostream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <ctime> 
#include <string>
#include <stdio.h>
#include <map>
#include <algorithm>

using namespace std;

map <string, int> m1;
string tokenizeReturnFirst(const string& str,const char& delimiters)
{
    string token;

    // skip delimiters at beginning.
    string::size_type lastPos = str.find_first_not_of(delimiters, 0);

    // find first "non-delimiter".
    string::size_type pos = str.find_first_of(delimiters, lastPos);
    if( pos!=string::npos)
    {
        token = str.substr(lastPos, pos - lastPos);
    }
    else
    {
        token = str;
    }


    return token;
}


int main()
{
        m1.insert(map <string, int> :: const_iterator::value_type("cd",0));        
        m1.insert(map <string, int> :: const_iterator::value_type("dir",0));        
        m1.insert(map <string, int> :: const_iterator::value_type("pwd",0));        
        m1.insert(map <string, int> :: const_iterator::value_type("echo",0));        
        m1.insert(map <string, int> :: const_iterator::value_type("help",0));        
        m1.insert(map <string, int> :: const_iterator::value_type("quit",0));        
        map <string, int> :: const_iterator m1_AcIter, m1_RcIter;
    typedef pair <string, int> Int_Pair;
    ifstream ifile( "test.bat");
    if ( ifile.fail() )
    {
        fprintf(stderr, "Cannot open %s\n", "output_file");
        return 0;
    }

    while (!ifile.eof())
    {
        string data_string ;
        getline(ifile,data_string);
        string command = tokenizeReturnFirst(data_string,string::value_type(' '));
        //std::transform( command.begin(), command.end(), command.begin(), ::tolower );
        cout<<"Searched string - "<<command <<endl;
        m1_AcIter   = m1.find(command);
        if(!command.empty())        
        {
            if(m1_AcIter  == m1.end())
            {
                cout<<"Didn't find unix command - "<< data_string<<endl ;
            }
            else
            { 
                cout<<"SYSTEM - "<< data_string.c_str()<<endl;
                system(data_string.c_str());
            }
        }
    }
    return 0;
}



Input file test.bat file content

<br />
ls<br />
pwd<br />
echo<br />
aaa<br />
quit 


now i tried to execute

Input

./a.out test.bat

Output:
<br />
Searched string - ls<br />
Didn't find unix command - ls<br />
Searched string - pwd<br />
Didn't find unix command - pwd<br />
Searched string - echo<br />
Didn't find unix command - echo<br />
Searched string - aaa<br />
Didn't find unix command - aaa<br />
Searched string - quit<br />
Didn't find unix command - quit<br />
Searched string - 



but file contain this command but output is wrong.
GeneralRe: STL map in UNIX Pin
Stuart Dootson4-Sep-09 23:59
professionalStuart Dootson4-Sep-09 23:59 
GeneralRe: STL map in UNIX Pin
Stuart Dootson5-Sep-09 0:02
professionalStuart Dootson5-Sep-09 0:02 
GeneralRe: STL map in UNIX Pin
Richard MacCutchan5-Sep-09 0:43
mveRichard MacCutchan5-Sep-09 0:43 
GeneralRe: STL map in UNIX Pin
ashukasama5-Sep-09 0:47
ashukasama5-Sep-09 0:47 
GeneralRe: STL map in UNIX Pin
Stuart Dootson5-Sep-09 6:13
professionalStuart Dootson5-Sep-09 6:13 
AnswerRe: STL map in UNIX Pin
Stuart Dootson4-Sep-09 23:54
professionalStuart Dootson4-Sep-09 23:54 
QuestionCListBox Pin
thanhvinh09064-Sep-09 17:46
thanhvinh09064-Sep-09 17:46 
AnswerRe: CListBox Pin
Code-o-mat5-Sep-09 8:42
Code-o-mat5-Sep-09 8:42 
QuestionC++ Queue Pin
jonig194-Sep-09 15:00
jonig194-Sep-09 15:00 
AnswerRe: C++ Queue Pin
Joe Woodbury4-Sep-09 19:05
professionalJoe Woodbury4-Sep-09 19:05 
AnswerRe: C++ Queue Pin
N a v a n e e t h4-Sep-09 20:35
N a v a n e e t h4-Sep-09 20:35 
AnswerRe: C++ Queue Pin
«_Superman_»4-Sep-09 22:47
professional«_Superman_»4-Sep-09 22:47 
AnswerRe: C++ Queue Pin
Stuart Dootson5-Sep-09 0:12
professionalStuart Dootson5-Sep-09 0:12 
QuestionHow to get number of the "CMDIChildWnd" initialized? Pin
transoft4-Sep-09 12:31
transoft4-Sep-09 12:31 
AnswerRe: How to get number of the "CMDIChildWnd" initialized? Pin
Randor 4-Sep-09 13:55
professional Randor 4-Sep-09 13:55 
QuestionGetting source code information from exception Pin
nachiket074-Sep-09 9:26
nachiket074-Sep-09 9:26 
AnswerRe: Getting source code information from exception Pin
Randor 4-Sep-09 9:53
professional Randor 4-Sep-09 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.