Oct 20, 2012 at 12:10am UTC
The only time you call convPunct is when isdigit(ch) returns true.
So, ch is guaranteed not to be any of the cases you have in the switch.
Oct 20, 2012 at 12:32am UTC
thanks for the response. I am sorry, but i honestly have no clue what you mean. Could you please point out the problem in code. Thanks
Oct 20, 2012 at 1:11am UTC
there's got to be somebody out there whom can help just point out the problem or push me in the right direction
Oct 20, 2012 at 2:00am UTC
Ok so I created a new function:
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 26 27 28 29
char convDigit (char ch)
{
char letter;
switch (ch)
{
case '0' :cout<<')' ;
break ;
case '1' :cout<<'!' ;
break ;
case '2' :cout<<'@' ;
break ;
case '3' :cout<<'#' ;
break ;
case '4' :cout<<'$' ;
break ;
case '5' :cout<<'%' ;
break ;
case '6' :cout<<'^' ;
break ;
case '7' :cout<<'&' ;
break ;
case '8' :cout<<'*' ;
break ;
case '9' :cout<<'(' ;
break ;
}
return letter;
}
and then changed the if statement
1 2 3 4 5
if (isdigit (ch))
{
decode=convDigit(ch);
total3++;
}
is that better? Or am I still doing something wrong?
Last edited on Oct 20, 2012 at 2:00am UTC
Oct 20, 2012 at 2:03am UTC
Looks good to me. Does it do what you want?
Oct 20, 2012 at 2:05am UTC
Nope for some reason the output still shows 0 even tho our teacher said:
Any character in msg that was a digit ('0' ... '9') was converted as follows:
0 --> )
1 --> !
2 --> @
3 --> #
4 --> $
5 --> %
6 --> ^
7 --> &
8 --> *
9 --> (
I have no clue why it still shows Digits: as 0
the text file should have 21 Digits
Last edited on Oct 20, 2012 at 2:05am UTC
Oct 20, 2012 at 2:35am UTC
....that was a complete copy of what i posted above.....wait...are you talking about the letter holding variable?
Last edited on Oct 20, 2012 at 2:39am UTC
Oct 20, 2012 at 2:38am UTC
Yes it was, the lines in bold indicate the problem.
are you talking about the letter holding variable?
Yup, see any problems?
Last edited on Oct 20, 2012 at 2:41am UTC
Oct 20, 2012 at 2:42am UTC
what do u mean that the letter holding variable is wrong? Could you please point out a fix to the problem. I am very very confused right now
Oct 20, 2012 at 2:43am UTC
Well, the value returned from convDigit() is the value written to file, you are returning letter
, but what does letter
equal? you never assign a value to it.
Last edited on Oct 20, 2012 at 2:45am UTC
Oct 20, 2012 at 2:47am UTC
How would I assign a value in the return section of a function? What would you do?
Oct 20, 2012 at 3:02am UTC
it did not work, but it's ok. I am limited on time, so I have to turn in with what I've got. Thanks for your help though. I really appreciated it.