Note that there are some explanatory texts on larger screens.

plurals
  1. POVisual C++ Weird Compiler errors
    primarykey
    data
    text
    <p>I'm trying to make an encryptor/decryptor using XOR method. I have done this before in Console C++, and I'm new to VC++, so I hope you can help me. The encryption works like this:</p> <pre><code>key = 3 x = 5 // The item being encrypted encryptedx = x ^ key // the "^" is XOR </code></pre> <p>So now, I want to make it in VC++, to make this look better that the Console window. In the design view in VC++, I have two rich text boxes, key edit box, and some buttons to start the process. It sounds really easy, but I get these errors:</p> <pre><code>------ Build started: Project: Encryptor, Configuration: Debug Win32 ------ 1&gt; Encryptor.cpp 1&gt;c:\users\**********c*********ncryptor\encryptor\Form1.h(264): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion) 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(707): could be 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;&amp;)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(762): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(767): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const _Elem *)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(772): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(_Elem)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; while trying to match the argument list '(std::string, System::String ^)' 1&gt;c:\*******gl\*****cryptor\encryptor\Form1.h(281): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion) 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(707): could be 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;&amp;)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(762): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(767): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(const _Elem *)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(772): or 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::operator =(_Elem)' 1&gt; with 1&gt; [ 1&gt; _Elem=char, 1&gt; _Traits=std::char_traits&lt;char&gt;, 1&gt; _Ax=std::allocator&lt;char&gt; 1&gt; ] 1&gt; while trying to match the argument list '(std::string, System::String ^)' ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== </code></pre> <p>And here is the code:</p> <pre><code>#include &lt;string&gt; #include "crypFunc.cpp" int key = 0; char tempChar; int stringLenght = 0; string strBuffer = ""; using namespace std; // // // // // private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { if(KeyBox-&gt;Text) { key =Convert::ToInt32(KeyBox-&gt;Text); numericUpDown1-&gt;Value = key; } } // // // // private: System::Void EncryptButton_Click(System::Object^ sender, System::EventArgs^ e) { EncryptedBox-&gt;Text = ""; strBuffer = DecryptedBox-&gt;Text; stringLenght = strBuffer.size(); if( strBuffer.size() &amp;&amp; key) { for(int i = 0; i &lt; stringLenght; i++) { tempChar = encrypt(strBuffer[i], key); EncryptedBox-&gt;Text = EncryptedBox-&gt;Text + tempChar; } } } private: System::Void DecryptButton_Click(System::Object^ sender, System::EventArgs^ e) { DecryptedBox-&gt;Text = ""; strBuffer = Convert::ToString(EncryptedBox-&gt;Text); stringLenght = strBuffer.size(); if( strBuffer.size() &amp;&amp; key) { for(int i = 0; i &lt; stringLenght; i++) { tempChar = decrypt(strBuffer[i], key); DecryptedBox-&gt;Text = DecryptedBox-&gt;Text + tempChar; } } } }; } </code></pre> <p>I really hope some of you can and want to help me. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload