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
4 Answers
+ 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.
+ 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..
+ 1
What are your bugs..?
It's working without bugs for me..
Is this not your full code?
0
Sorry, I posted the wrong link. Try now.