Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Escreva um programa que pede ao usuário digitar uma string S e dois caracteres X e
- Y e troque todas as ocorrências de X em S por Y*/
- #include <stdio.h>
- #include <string.h>
- #define tam 10
- int main(){
- char s[tam], x, y;
- int i;
- printf("\nEscreva uma string:\n");
- fgets(s,tam,stdin);
- printf("\nInforme o caractere x\n");
- scanf("%c",&x);
- printf("\nInforme o caractere y\n");
- scanf("%c",&y);
- for(i=0;i<tam;i++){
- if(tolower(s[i])=='x'){
- s[i]=='y';
- }
- }
- printf("\n %s",s[tam]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement