3
Good afternoon, you guys!
I have a problem in Strings using the C Language.
The problem asks the user to enter a name, then to enter a special character, and finally how many times he wants the character to be concatenated with the String. However, concatenation should only be performed with the last vowel of the string.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char nome[100]="Celular";
char letra[100];
int qtd=0;
printf("Nome definido: %s\n\n", nome);
printf("\nCARACTER que deseja INCLUIR no nome ");
scanf(" %c",&letra);
printf("\nQuantidade de vezes que deseja colocar no nome? ");
scanf(" %d",&qtd);
for(int i=0;i<qtd;i++){
strncat((nome), letra, 1 );
}
printf("resultado = %s\n ", nome);
system("PAUSE");
return 0;
}
The code will add the special character at the end of the string. However, I didn’t understand how to add it in the last vowel of the string.
The problem of vowel absence in a user input could not be solved using a drop in 1for ? If you can’t find a vowel direct to the end of the program.
– Igor PTZ
Could create a variable
int x=-10
then at the end of the first cycleif(x==-10)
did the end drop like I said.– Fábio Morais