इस लेख में हम C++ में iswpunct() फंक्शन, इसके सिंटैक्स, वर्किंग और इसके रिटर्न वैल्यू पर चर्चा करने जा रहे हैं।
iswpunct() फ़ंक्शन C++ में एक इनबिल्ट फ़ंक्शन है जिसे
विराम चिह्न इस प्रकार हैं
! @ # $ % ^ & * ( ) “ ‘ , . / ; [ { } ] : ? सिंटैक्स
int iswpunct(wint_t ch);
फ़ंक्शन केवल एक पैरामीटर को स्वीकार करता है, यानी एक विस्तृत वर्ण जिसे जांचना है। तर्क को wint_t या WEOF में डाला गया है।
wint_t एक अभिन्न प्रकार का डेटा संग्रहीत करता है।
रिटर्न वैल्यू
फ़ंक्शन एक पूर्णांक मान देता है, जो या तो 0 (गलत के मामले में) या कोई गैर-शून्य मान (सत्य के मामले में) हो सकता है।
उदाहरण
#include <iostream>
#include <cwctype>
using namespace std;
int main() {
wint_t a = '.';
wint_t b = 'a';
wint_t c = '1';
iswpunct(a)?cout<<"\nIts Punctuation character":cout<<"\nNot Punctuation character";
iswpunct(b)?cout<<"\nIts Punctuation character":cout<<"\nNot Punctuation character";
iswpunct(c)?cout<<"\nIts Punctuation character":cout<<"\nNot Punctuation character";
} आउटपुट
यदि हम उपरोक्त कोड चलाते हैं तो यह निम्न आउटपुट उत्पन्न करेगा -
Its Punctuation character Not Punctuation character Not Punctuation character
उदाहरण
#include <iostream>
#include <cwctype>
using namespace std;
int main () {
int i, count;
wchar_t s[] = L"@tutorials, point!!";
count = i = 0;
while (s[i]) {
if(iswpunct(s[i]))
count++;
i++;
}
cout<<"There are "<<count <<" punctuation characters.\n";
return 0;
} आउटपुट
यदि हम उपरोक्त कोड चलाते हैं तो यह निम्न आउटपुट उत्पन्न करेगा -
There are 4 punctuation characters.