Please help in the code coach challenge? | Sololearn: Learn to code for FREE!


Please help in the code coach challenge?

I have got a mistake in symbols code coach challenge and the mistake is in #4. Please help me to solve this problem using C

11/20/2020 11:28:24 AM


3 Answers

New Answer


Since you don't copy the null character over to "copy", you need to null-initialize the string, otherwise puts() will continue writing characters until it finds a random null character in memory, which might or might not be at the end of the string. Simply change the initialization to char sentence[ 100 ] = {}, copy[ 100 ] = {}; and the solution will be fine. Two notes: The code is written in C, not C# - you might want to edit your question/ tags to that effect. Also, it is advised to avoid gets() in favor of either scanf() or fgets():


copy[k]='\0'; Just append a null to char array just after the loop


You don't actually need copy[100], if the condition is satisfied, print it out. You can also use isalnum() instead of isalpha & isdigit together.