Function is: all the letters in the string s rewritten to the next letter of the alphabet, the letter z rewritten letter a. Still requires capital letters uppercase letters, lowercase letters remain lowercase letters, other characters do change.
Please write function chg (char * s) required to achieve the program, after calling the function readwriteDAT () the output to a file bc1.out in.
For example: s the string is any original content: Mn.123Zxy, this function is called, the result is: No.123Ayz.
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#define N 81 void readwriteDAT();
void chg(char *s)
{int I;
for(I=0;I<strlen(s);I++)
if(s[i]‘z’||s[i]‘Z’)s[i]-=25;
else if(s[i]>=‘a’&&s[i]<=‘y’||s[i] >=‘A’&&s[i]<=‘Y’) s[i]+=1;
}
main( )
{
char a[N];
clrscr();
printf("Enter a string : "); gets(a);
printf("The original string is : "); puts(a);
chg(a);
printf("The string after modified : ");
puts (a);
readwriteDAT() ;
}
void readwriteDAT()
{
int i ;
char a[N] ;
FILE *rf, *wf ;
rf = fopen(“bc1.in”, “r”) ;
wf = fopen(“bc1.out”, “w”) ;
for(i = 0 ; i < 50 ; i++)
{
fscanf(rf, “%s”, a) ;
chg(a) ;
fprintf(wf, “%s\n”, a) ;
}
fclose(rf) ;
fclose(wf) ;
}