Why can't my Morse code converter work properly? | Sololearn: Learn to code for FREE!


Why can't my Morse code converter work properly?

https://code.sololearn.com/csWImHpEBGQH/#c my converter can work properly around letters,but it dosen't work right with digits,if you submit some numbers on this web compiler,there is no output but no errors either,and it happens similar on codeblocks. i checked my code again and again,but still can't find the problem,someone help me,please!


10/8/2018 12:51:22 PM

Penghua Chen

2 Answers

New Answer


in traditional char array you'll need extra space for \0 your array size is [5] that means you only have 4 space for character, it works perfectly with letters but number need 5 symbol that means you'll lack of 1 space for \0. change your array size to 6 :)


The problem is that you are checking for strings instead of integers. Replace line 31 with this: else if (chr[0]>=0&&chr[0]<=9)