Fungsi isspace () di C ++ memeriksa apakah karakter yang diberikan adalah karakter spasi atau bukan.
isspace () Prototipe
int isspace (int ch);
The isspace()
pemeriksaan fungsi jika ch adalah karakter spasi sebagai diklasifikasikan oleh C lokal saat ini. Secara default, karakter berikut adalah karakter spasi:
- spasi (0x20, '')
- formulir umpan (0x0c, ' f')
- umpan baris (0x0a, ' n')
- kereta kembali (0x0d, ' r')
- tab horizontal (0x09, ' t')
- tab vertikal (0x0b, ' v')
Perilaku isspace()
tidak terdefinisi jika nilai ch tidak dapat direpresentasikan sebagai unsigned char atau tidak sama dengan EOF.
Ini didefinisikan dalam file header "> file header.
Parameter isspace ()
ch: Karakter yang akan diperiksa.
isspace () Nilai kembali
The isspace()
fungsi mengembalikan nilai non nol jika ch adalah karakter spasi, jika tidak kembali nol.
Contoh: Bagaimana fungsi isspace () bekerja
#include #include #include using namespace std; int main() ( char str() = " C++"; cout << "Before removing whitespace characters" << endl; cout << str << endl << endl; cout << "After removing whitespace characters" << endl; for (int i=0; i
When you run the program, the output will be:
Before removing whitespace characters C++ After removing whitespace characters C++