A processing function for file median operations.

Source: Internet
Author: User

[Cpp]
The ReadDat () function reads an English article from the file IN88.DAT and saves it to the string array xx. Compile the CharConvA () function. Its function is to shift the ASCii value of the last character of the string to four places by behavior units and then add the ASCii value of the last second character, get the last new character. the ASCii value of the last second character shifts to four places and then adds the ASCii value of the last third character to get the second new character, and so on, it is processed until the second character. the ASCii value of the first character is added with the ASCii value of the last character to obtain the first new character, the new characters are respectively stored in the corresponding position of the original string, and the processed strings are restored in the string array xx by row. Finally, the WriteDat () function is called () output The result xx to the OUT88.DAT file.
[Cpp]

[Cpp]

[Cpp]

[Cpp]
# Include <stdio. h>
# Include <string. h>
# Include <windows. h>
# Include <conio. h>
Char xx [50] [80];
Int maxline = 0;
Int ReadDat ();
Void WriteDat ();
Void CharConvA (void)
{
Int j, k, s;
Char ch;
For (j = 0; j <maxline; j ++)
{
S = strlen (xx [j]);
Ch = xx [j] [s-1];
For (k = s-1; k> 0; k --)
Xx [j] [k] = (xx [j] [k]> 4) + xx [j] [k-1];
Xx [j] [0] = xx [j] [0] + ch;
}
}
Void main ()
{
System ("cls ");
If (ReadDat ())
{Printf ("the data file IN88.DAT cannot be opened! \ N \ 007 "); return ;}
CharConvA ();
WriteDat ();
}
Int ReadDat (void)
{
FILE * fp;
Int I = 0;
Char * p;
If (fp = fopen ("IN88.DAT", "r") = NULL) return 1;
While (fgets (xx [I], 80, fp )! = NULL)
{
P = strchr (xx [I], '\ n ');
If (p) * p = 0;
I ++;
}
Maxline = I;
Fclose (fp );
Return 0;
}
Void WriteDat ()
{
FILE * fp;
Int I;
System ("cls ");
Fp = fopen ("OUT88.DAT", "w ");
For (I = 0; I <maxline; I ++)
{Printf ("% s \ n", xx [I]); fprintf (fp, "% s \ n", xx [I]);}
Fclose (fp );
}
[Cpp]

 

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.