Really, that's not a good reason.
If you have a good reason, use them. If you don't, then don't. It's bad practice.
A small app is just not a good reason. Don't get into the habit of doing it!
Printable View
Wouldn't it be much easier to read this way:Code:if(input[aa]=='a'||input[aa]=='d'||input[aa]=='g'||input[aa]=='j'||input[aa]=='m'||input[aa]=='p'||input[aa]=='s'||input[aa]=='w')
{
input[aa]='*';
}
else
{
if(input[aa]=='b'||input[aa]=='c'||input[aa]=='d'||input[aa]=='e'||input[aa]=='f'||input[aa]=='g'||input[aa]=='t'||input[aa]=='x') {
output[aa]='*';
bb=aa;
bb++;
output[bb]='*';
bb=0;
}
else
{
output[aa]='*';
bb=aa;
bb++;
output[bb]='*';
bb++;
output[bb]='*';
bb=0;
I have no idea what your code is actually intending to do, so I have no idea if the above code is actually correct - it's just a replacement of your long if-statements with switch - which makes it easier to read. strchr() as suggested is also an option, but it's a bit of a roundabout way to do it.Code:switch (input[aa])
{
case 'a':
case 'd':
case 'g':
case 'j':
case 'm':
case 'p':
case 's':
case 'w':
input[aa]='*';
break;
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
case 'g':
case 't':
case 'x':
output[aa]='*';
bb=aa;
bb++;
output[bb]='*';
bb=0;
break;
default:
output[aa]='*';
bb=aa;
bb++;
output[bb]='*';
bb++;
output[bb]='*';
bb=0;
}
--
Mats
I do indeed use cin>>input;, but if i do this:
it comes with spaces, so I dont understand what you mean, but ill try cin.getline( input, 100, '\n' )Code:cin>>input;
cout<<input;
EDIT: it works with cin.getline( input, 100, '\n' ), thank you, i dont understand why thow.