-2
I’m trying to do a function with only these two libraries and without changing the main function check that the word is palindromic.
She must have the following exit:
radar eh palindromo!
rada nao eh palindromo!
But I tried some things and I can not understand the logic. Below the code:
#include <stdio.h>
#include <stdlib.h>
int palindromo(char* texto, int n) {
*/completar aqui/*
return 1;
}
int main() {
char* p1 = (char*) malloc(sizeof(char)*5);
p1[0] = 'r';
p1[1] = 'a';
p1[2] = 'd';
p1[3] = 'a';
p1[4] = 'r';
if(palindromo(p1,5)){
printf("radar eh palindromo!\n");
}else{
printf("radar nao eh palindromo!\n");
}
if(palindromo(p1,4)){
printf("rada eh palindromo!\n");
}else{
printf("rada nao eh palindromo!\n");
}
return 0;
}
If anyone can help me, I’d really appreciate it.
At the end you just wrote a
main
to test a function you haven’t written and are asking for help. Sorry, but Porfavornosajude to help you. Follow a site search where several people have asked about palindromes with the tag [tag:c].– fernandosavio
I wrote yes, it just didn’t work, so I left the "complete here" to be clearer where I should move. I’m tired of asking here on this site and seeing people like you who would rather lecture than teach to do, just like the comment from below did and was very professional and helpful. Not everyone already has the vast knowledge of programming that most people here do. @fernandosavio
– Porfavormeajude
I really understand that you must be tired of asking here and your questions being closed, I don’t always agree with closures. But that doesn’t change the fact that your question doesn’t have any code that you tried. I can’t read your question and guess that you tried something and what didn’t work out in what you tried. And the site is full of people who just post a college exam question and expect some volunteer come answer. So it’s not a moral lesson, but an ear-jerk because if you did it in real life it would also catch up badly.
– fernandosavio
Even if it didn’t work, putting the code you tried is better than not putting - because at least there we can see where the difficulty is and doesn’t give the impression that nothing has been done and you just want everything ready (the "complete here" passes just this impression). This also helps to avoid closing, since questions like "do it for me" are outside the scope. I suggest a read on Checklist, in the FAQ and in the Guidebook
– hkotsubo
Yes, it’s a lot to read, but I assure you that if you understand and follow everything there, you will enjoy the site better :-)
– hkotsubo