The standard C ++ uses all spaces of the string object %%%%%%%%%%%%to go to the left and right Space Code. It is better to write it on the internet for half a day.

Source: Internet
Author: User
Tags rtrim
Str. Erase (remove_if (Str. Begin (), str. End (), ptr_fun (isspace), str. End ());
Who can send better messages?
Evaluate the Left and Right Spaces Code .
Tchar tempname [256] = {0 };
Tchar temptype [256] = {0 };
Fscanf (FP, "% s", temp); // obtain the field name
// Continue;
For (INT I = 0; I <strlen (temp); I ++ ){
Tempname [I] = temp [I];
}
Fgets (temp, 256, FP); // obtain the field type.
For (INT I = 0; I <strlen (temp); I ++ ){
Temptype [I] = temp [I];
}
Trim (temptype );
Trim (tempname );

// Remove the left space function
Tchar * creadmifdoc: ltrim (tchar * temp) {// * temp = temp [0]
Int Len = strlen (temp );
Tchar tempstr [256] = {0 };
For (INT I = 0; I <len-1; I ++)
{
If (temp [I]! = ''){
For (Int J = 0; I <len-1; j ++, I ++ ){
Tempstr [J] = temp [I];
}
Break;
}
}
Return tempstr;
}
// Remove right space function
Tchar * creadmifdoc: rtrim (tchar * temp ){
Int Len = strlen (temp );
For (INT I = Len; I> = 0; I --){
If (temp [I-2]! = '') {// Temp [I-2] is the penultimate element, temp [I-1] = '\ 0'
Temp [I] = '\ 0 ';
Break; // The Terminator truncates the character array.
}
}
Return temp;
}

Tchar * creadmifdoc: trim (tchar * temp ){
Return ltrim (rtrim (temp ));
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.