Why can't my Morse code converter work properly? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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!

8th Oct 2018, 12:51 PM
Penghua Chen
Penghua Chen - avatar
2 Answers
+ 1
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 :)
8th Oct 2018, 2:12 PM
Taste
Taste - avatar
+ 1
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)
8th Oct 2018, 2:13 PM
ReimarPB
ReimarPB - avatar