1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
void mycode(char msg[ ],char ch)
{
for (int cnt=0;msg[cnt]='\0';cnt++)
{
if ((msg[cnt]>='B')&&(msg[cnt]<='G'))
msg[cnt]=tolower(msg[cnt]);
else if ((msg[cnt]=='A')||(msg[cnt]=='a'))
msg[cnt]=ch;
else if ((cnt%2)==0)
msg[cnt]=toupper(msg[cnt]);
else
msg[cnt]=msg[cnt-1];
}
}
int main()
{
char mytext[20]="ApEACeDriVE";
mycode(mytext, '@');
cout<<"NEW TEXT: "<<mytext<<"\n";
return 0;
}
|
The output I'm getting is:
Last edited on
Line 7 look dubious. Didi you mean != '\0' ?