jeudi 1 août 2019

Problem with writing elements of an array using the pointer

The first loop is works perfect. Second doesn't works. What is wrong with 'Z'. Why the loop doesn't stop? When I will give 'Z' inside in table the loop doesn't react.

#include <iostream>
using namespace std;

int main()
{
    char tab[] { 'A', 'B', 'C', 'D', 'E', 'F', 'G',
                'H', 'I', 'J', 'K', 'L', 'M', 'N',
                'O', 'P', 'Q', 'R', 'S', 'T', 'U',
                'V', 'W', 'X', 'Y', 'Z' };

    char *wsk = tab;

    while(*wsk <= 'Y')
    {
        cout << *wsk << " ";
        wsk++;
    }
    cout << endl;

    wsk = tab;
    while(*wsk <= 'Z')
    {
        cout << *wsk << " ";
        wsk++;
    }
    cout << endl;
}


Aucun commentaire:

Enregistrer un commentaire