+ 1
HEY🤗! can you find the BUG 🧐
#include<stdio.h> #include<string.h> char resort(); int main() { static char *arr; gets(arr); printf("%s",resort(arr)); return 0; } char resort(char *gap) { int m,index=0; static char *sort; m=strlen(gap); for(int i=m;i>=0;i--) { if((gap[i]>='a')&&(gap[i]<'z') && (gap[i]>='A')&&(gap[i]<='Z')); { sort[index]=gap[i]; ++index; } } return sort; }
4 Answers
+ 2
Recheck your if condition in the for loop.
Should be;
if (gap[i] >= 'a' && gap[i] <= 'z' || gap[i] >= 'A' && gap[i] <= 'Z' || gap[i] == ' ')
Also, check your return type for the function
For loop also should initialize i to m-1 not m to account for the null char '\0'
Also, append the null char to the end (index) of sort
You also need to allocate and free the memory for your arrays. (no need for static)
+ 2
Дилшод Усмонов Here's my solution:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char *decipher(char *str) {
static char out[75];
for (int i=0,j=strlen(str)-1;1;j--) {
if (j < 0) {
out[i] = 0;
return out;
}
if (isalpha(str[j]) || str[j] == 32) out[i++] = str[j];
}
}
// Hope this helps
+ 1
I WANT TO SOLVE THIS PUZLE
You are a secret agent, and you receive an encrypted message that needs to be decoded. The code that is being used flips the message backwards and inserts non-alphabetic characters in the message to make it hard to decipher.
Task:
Create a program that will take the encoded message, flip it around, remove any characters that are not a letter or a space, and output the hidden message.
Input Format:
A string of characters that represent the encoded message.
Output Format:
A string of character that represent the intended secret message.
Sample Input:
d89%l++5r19o7W *o=l645le9H
Sample Output:
Hello World
0
We pray too