| |

VerySource

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

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-9 13:00:02
| Show all posts |Read mode
// Validate the input data
if (m_old.GetLength ()! = 8)
{
MessageBox ("Please enter 8 clear text", "Friendly Tips");
return;
}
This code is to verify whether the input data is 8 digits, or it will prompt to enter again. Now it is necessary to fill in 8 bits with 0 if the input data is less than 8 bits. How can prawns be realized? Please elaborate, I am a rookie just learning VC. I don't understand the format method.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

Post time: 2020-5-31 09:45:01
| Show all posts
if (m_old.GetLength () <8)
{
  for (int n = m_old.GetLength (); n <8; n ++)
    m_old + = '0';
}
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-6-1 01:00:01
| Show all posts
Upstairs is the last 0, the first 0 is as follows
if (m_old.GetLength () <8)
{
  CString str;
  for (int n = m_old.GetLength (); n <8; n ++)
      str + = '0';
    m_old + = str;
}
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-9 11:45:01
| Show all posts
The upstairs is wrong, the first 0 should be
if(m_old.GetLength()<8)
{
  CString str;
  for(int n = m_old.GetLength();n<8;n++)
      str += '0';
    m_old = str+m_old;
}
Reply

Use magic Report

4

Threads

15

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-9 18:00:01
| Show all posts
The above two, what is the difference between your code.
Reply

Use magic Report

0

Threads

14

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-6-12 02:30:01
| Show all posts
m_old+=str; is equivalent to m_old=m_old+str; is 0
m_old = str+m_old; is the first 0
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