0
I’m having problems in my function that checks the existence of a specific letter in a string (I don’t know much about pointers I only used because my other function wasn’t returning the string if it wasn’t by pointer.)
How I declared my string within the class:
char *nome[tamanho];
My job:
int Charclass::verificar_letra_existente(){
char *a;
int i;
int valorretornado;
printf("digite uma letra:\n");
scanf("%c",*a);
for(i=0;i<tamanho;i++)
{
if(*nome[i]==*a){
printf("ACHAMOS A LETRA NA STRING, ESTA NA POSICAO:");
return i;
}
}
printf("NAO ACHAMOS UMA LETRA NA STRING :\n");
}
What mistakes have appeared?
– user142154
it asks the letter to check the string, when I type it closes the program, it doesn’t even check if it exists in the string. @v.Santos
– Vitor Gonçalves
tamanhois a global constant? What value are you starting it with? Edit your question to put also, at least, the class constructorcharClass. It would also help if you put the snippet where you are instantiating the object of this class and the snippet that you are invoking the methodverificar_letra_existente(). @Victor.– user142154
as I had said I don’t know how to work with pointers, my teacher told me to use pointers only in the function that returns string, so I won’t need the code anymore, thanks @v.Santos
– Vitor Gonçalves
format the code with indentation and spaces, otherwise it becomes more difficult to understand...
– zentrunix