Code: Getting char array's last character
This code will seek the ubound of a char array. Not really the ubound, just the last inputted character. Kind of like a Len() function.
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int i;
char name[65536];
long ubound;
ubound = 0;
cout <<"Please enter your name: ";
cin >> name;
for (i=0; i<65536; i++)
{
if (name[i] == NULL){
if (ubound == 0){
ubound = i;
}
}
}
for (int x=0; x<ubound; x++)
{
cout << "Character " << x + 1 << " is " << name[x] << ". \n";
}
return 0;
}