Fungsi iswgraph () di C ++ memeriksa apakah karakter lebar yang diberikan memiliki representasi grafis atau tidak.
Fungsi iswgraph () didefinisikan dalam file header.
prototipe iswgraph ()
int iswgraph (wint_t ch);
Fungsi iswgraph () memeriksa apakah ch memiliki representasi grafis yang diklasifikasikan oleh lokal C saat ini. Secara default, karakter berikut adalah grafik:
- Digit (0 hingga 9)
- Huruf besar (A sampai Z)
- Huruf kecil (a sampai z)
- Karakter tanda baca (! "# $% & '() * +, -. /:;? @ () _` (|) ~)
iswgraph () Parameter
- ch: Karakter lebar untuk diperiksa.
iswgraph () Nilai kembali
- Fungsi iswgraph () mengembalikan nilai bukan nol jika ch memiliki karakter representasi grafis.
- Ia mengembalikan nol jika ch tidak memiliki karakter representasi grafis.
Contoh: Bagaimana fungsi iswgraph () bekerja?
#include #include #include using namespace std; int main() ( setlocale(LC_ALL, "en_US.UTF-8"); wchar_t ch1 = L'u0009'; wchar_t ch2 = L'u03a9'; iswgraph(ch1)? wcout << ch1 << L" has graphical representation" : wcout << ch1 << L" does not have graphical representation"; wcout << endl; iswgraph(ch2)? wcout << ch2 << L" has graphical representation" : wcout << ch2 << L" does not have graphical representation"; return 0; )
Saat Anda menjalankan program, hasilnya adalah:
tidak memiliki representasi grafis Ω memiliki representasi grafis