punctuation character

Can you tell me what is wrong whit this code. I want it to remove all punctuation characters but the output is always empty. Correct this code please.

#include <iostream>

#include <stdio.h>

#include <ctype.h>

#include <string>

using namespace std;


int main()
{
int i,j,k;
string recenica;
char slova[91];
char brojevi[58];
char rec[50000];
bool pomoc;

printf("Unesi jednu recenicu! \n");
scanf("%s",rec);

for (i=65;i<91;i++)
{
slova[i-64]=char(i);
};
for(i=48;i<58;i++)
{
brojevi[i-47]=char(i);
};
for (i=1;i=(sizeof(rec));i++)
{
pomoc=true;
for (j=0;j<10;j++)
{
if (rec[i]!=brojevi[j]) pomoc=false;
};
for (k=0;k<26;k++)
{
if (rec[i]!=(tolower(slova[k]))) pomoc=false;
};
if (pomoc==false) recenica+=rec[i]; else recenica+=' ';

};
cout << recenica << endl;
system("pause");
return 0;
}
For starters, this probably isn't what you want:

for (i=1;i=(sizeof(rec));i++)

Please format your code better and post it in code tags (the # symbol to the right).
Here I now declared rec as a string. Now output is first 4 character of the sentence.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>

 #include <stdio.h>
 
  #include <ctype.h>
  
   #include <string>
   
     using namespace std;
     
     
      int main()
{
    int i,j,k;
    string recenica,rec;
    char slova[90];
    char brojevi[57];
    bool pomoc;
    
    printf("Unesi jednu recenicu! \n");
    getline(cin,rec);
    
    for (int i=65;i<=90;i++)
    {
        slova[i-64]=char(i);
    };
    for(int i=48;i<=57;i++)
    {
                      brojevi[i-47]=char(i);
    };
    for (int i=0;i<(sizeof(rec));i++)
    {
        pomoc=true;
        for (int j=0;j<10;j++)
        {
            if (rec[i]!=brojevi[j]) pomoc=false;
        };
        for (int k=0;k<26;k++)
        {
            if (rec[i]!=(tolower(slova[k]))) pomoc=false;
        };
        if ( pomoc!=true ) recenica+=rec[i]; else recenica+=' ';
        
    };
    
    cout << recenica << endl;
    
    system("pause");
    return 0;
}
      
    
Ou I solved it.
Please get rid of your system call, there are better ways of pausing the program.
Topic archived. No new replies allowed.