0

Can You help me with my C program?

I have a massive amount of mysterious bugs I can't understand. Example: https://code.sololearn.com/cQcfQ64SZjb0/#c

1st Dec 2020, 8:12 PM
OverdrivedProgrammer
4 Respostas
+ 3
You need to change the first input to something like scanf( "%s ", action ) or scanf( "%s\n", action ) because otherwise the newline character entered after the action will remain in the input buffer and be read by fgets() instead of the message. By changing scanf() accordingly, you consume the newline character and remove it from the input buffer. Furthermore, you read the message into the "textp" variable, but then pass the empty "text" variable to your functions, which doesn't make sense. There is also the problem that "textp" is an array of char pointers, not a string, so storing the message inside is an issue. Maybe you meant to use "text" instead.
1st Dec 2020, 8:48 PM
Shadow
Shadow - avatar
+ 2
I don't understanding your encryption policy. Just saying errors : for(int i = 0; i < 99; i=i + 2){//1 Just putting i+2 will not work. Put i=i+2 fullEncrypt[comp] = '-'; for charecter assignments use single quotes. Double quotes are used for string assignments.. Ndxt putting p=0,i=0 may make infinite loop.. Why there p=0? Next if part has no proper braces added.. In this : // int p = 0; //progress if (decryptions[i] == text[p]){ text[p] = i; //I will make a real encryption later. Should I do it right now?(Q4) } //3 if (i == 68){ text[p] = 'X'; //here same use single quotes... This is not used anywhere, just remove or comment.. // char encrypted_text[50]; Besides this, you set isfinished=fakse; so if part never gets executing.. It always else part gets executing... Making all these changes makes your program executed without errors. But for correct output, correct the logic of encryption,description..
2nd Dec 2020, 7:17 PM
Jayakrishna 🇮🇳
+ 1
What are your bugs..? It's working without bugs for me.. Is this not your full code?
1st Dec 2020, 8:43 PM
Jayakrishna 🇮🇳
0
Sorry, I posted the wrong link. Try now.
2nd Dec 2020, 5:19 PM
OverdrivedProgrammer