How I take the space from the char when I type more than one word does not appear / on type the phrase

Asked

Viewed 33 times

0

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <ctype.h>

#define MAX 400

using namespace std;

int main()
{
setlocale(LC_ALL, "portuguese");

char a, b;
char f[MAX];

cout << "Digite o 1º caracter" << endl;
cin >> a;
cout << "Digite o 2º caracter" << endl;
cin >> b;

cout << "Digite a frase: " << endl;
cin >> f;

cout << endl;

char si[100]= {a, b, toupper(a), toupper(b)};

cout << f << endl;

for(int i =0; i< strlen(f); i++){
    int c=0;
    for(int v =0; v<100; v++){
        if(f[i] == si[v]) c= 1;
    }
    if(c == 1){
        f[i] = '*';
    }
}

cout << f << endl;

getchar();
return 0;
}
  • I think you should review how Cin works. Evaluate if getline would not be better for what you want. Avoid mixing C with C++.

  • in good, I didn’t understand anything of your question.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.