#include<iostream.h>
int puncmarks(){
char j;
cin>>j;
for( ;j=='!'||'"'||'#'||'$'||'%'||'&'||'()'||'*'||'+'||','||'- '||'.'||'/'||':'||';'||'<'||'='||'>'||'?'||'@'||'['||'\'||']'||'^'||'_'||'`'||'{'||'}'||'~'||'.'||')'; )
return 1;
return 0;
main(){
cout<<puncmarks()<<endl;
}
Asked
Active
Viewed 41 times
0

463035818_is_not_an_ai
- 109,796
- 11
- 89
- 185
-
what is the for loop supposed to do? To check `if` a condition is satisfied, you would typically use `if` – 463035818_is_not_an_ai Jun 02 '20 at 12:05
-
Char is 1 character, just use switch (j) or add those to array then with for loop check all if they fit the regex. – Dressy Fiddle Jun 02 '20 at 12:05
-
4`if (std::ispunct(j))`?. Also, you should never, in a real-life program, assume what the punctuation characters are. That's the job of `ispunct()`. – PaulMcKenzie Jun 02 '20 at 12:06
-
you can use [`std::any_of`](https://en.cppreference.com/w/cpp/algorithm/all_any_none_of) – 463035818_is_not_an_ai Jun 02 '20 at 12:06
-
I do not understand pleas anyone solve it without if (std::ispunct(j))? – Jun 02 '20 at 12:13
-
even thous ispunct() checks if a character is classified as punctuation by a locale he is still learning and should try to solve it himself.. link: https://en.cppreference.com/w/cpp/string/byte/ispunct – Dressy Fiddle Jun 02 '20 at 12:13
-
@DressyFiddle The solution is `ispunct()`. Anything else is shoddy C++ coding and practice. – PaulMcKenzie Jun 02 '20 at 12:20