// String comparison using pointers to char
#include <iostream>
using std::cout;
using std::endl;

int main()
{
    char *pstr1 = "NCNU";
    char *pstr2 = "NCNU";
    bool flag;
    char *p1, *p2;

    flag = true;
    p1 = pstr1; p2 = pstr2;
    while (flag && *pstr1 != '\0')
    {
        if (*pstr1 != *pstr2)
	    flag = false;
	pstr1++; pstr2++;
    }
    if (flag && *pstr2 != '\0')
        flag = false;

    if (flag)
        cout << "str1 is the same as str2." << endl;
    else
        cout << "str1 differs from str2." << endl;
    return 0;
}
