I have program I am writing that takes encrypted strings from a txt file and decrypts char by char. I am just gonna post the loop with which I am having the issue. Some notes about what is missing from code snippet:
Declaration and initialization of map<char,char> codes
Declaration and opening of fstream inFile, loginFile
Declaration of string userComp , passComp;
I have tried changing out the cout portions with loginFile << codes.at(c)
The error says:
An enclosing-function local variable cannot be referenced in the lambda body unless it is in the capture list
However, I am unsure of the proper way and syntax needed to add to capture list.
This code works, but instead of printing to console, I need it to write to my loginFile
while (!inFile.eof())
        {
            getline(inFile, nameComp, ',');
            getline(inFile, passComp, '\n');
            for_each(nameComp.begin(), nameComp.end(), [codes](char c)
            {
                 cout << codes.at(c);
            });
            for_each(passComp.begin(), passComp.end(), [codes](char d)
            {
                cout << codes.at(d);
            });
            cout << endl;
        } 
I am looking for a specific solution involving the current code, but if there is a better way to achieve this I am open to changing my code.
 
     
    