| |

VerySource

 Forgot password?
 Register
Search
View: 696|Reply: 5

What should I do to achieve the following functions under VC ++?

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-4 12:30:02
| Show all posts |Read mode
// Validate the input data
if (m_old.GetLength ()! = 8)
{
MessageBox ("Please enter 8 clear text", "Friendly Tips");
return;
}
if (m_key.GetLength ()! = 8)
{
MessageBox ("Please enter 8-digit cipher text", "Friendly Tips");
return;
}
In plain text input, if the input data is less than 8 bits, it is treated as 0's complement. How to implement such code. I am newbie, please help prawns!
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-5-18 12:00:01
| Show all posts
int num = m_old.GetLength ();
if (num! = 8)
{
char cAdd [8-num];
int i;
for (i = 0; i <8-num; i ++)
    cAdd [i] = '0';
CString str;
str.Format ("% c", cAdd);

m_old = m_old + str;
// or m_old = str + m_old;

// MessageBox ("Please input 8 plain text", "Friendly prompt");
// return;
}
Reply

Use magic Report

0

Threads

32

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 Invalid IP Address

Post time: 2020-5-18 12:15:01
| Show all posts
> .. In the input of plain text, if the input data is less than 8 bits, it will be compensated by 0. How to implement such code ...
-------------------------------------------------
You are using CString, right, you can use Format method, for example:
int nABC = 2;
CString strABC;
strABC.Format ("% 08d", nABC);
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-23 23:00:01
| Show all posts
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-23 23:15:01
| Show all posts
I just tried it on the machine. The following error appears. How to deal with it?
E:\DESChecker\DESDlg.cpp (354): error C2057: expected constant expression
E:\DESChecker\DESDlg.cpp (354): error C2466: cannot allocate an array of constant size 0
E:\DESChecker\DESDlg.cpp (354): error C2133: 'cAdd': unknown size
An error occurred while executing cl.exe.
Reply

Use magic Report

1

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-8-5 00:30:01
| Show all posts
sorry, there is a mistake, it should be
int num = m_old.GetLength();
if(num!=8)
{
char cAdd[9];
int i;
for(i=0; i<8-num; i++)
    cAdd[i]='0';
cAdd[8-num]='\0';
CString str;
str.Format("%s",cAdd);
//cAdd;
//Or m_old = m_old + str;
m_old = str + m_old;
//MessageBox("Please enter 8-digit plaintext", "Friendly Tips");
//return;
}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list