#include<iostream.h>
#include <conio.h>
int main(){
const int aSize=25;
char arr[aSize];
char* pChar;
int i = 0;
int nameSize;
pChar = arr;
cout << "Enter a name: ";
for (i=0; i<aSize; i++){
*(pChar+i)=getch();
// --- If Enter is pressed, stop copying and break out of the for loop
if (arr[i] == '\r'){
cout << endl;
nameSize=i; // storing the size of the name
break;
} // end if
cout << arr[i];
} // end for - Array arr
// Displaying Array
cout << endl;
for (i=0; i<nameSize; i++)
cout << arr[i];
return 0;
} // end main()
#include <conio.h>
int main(){
const int aSize=25;
char arr[aSize];
char* pChar;
int i = 0;
int nameSize;
pChar = arr;
cout << "Enter a name: ";
for (i=0; i<aSize; i++){
*(pChar+i)=getch();
// --- If Enter is pressed, stop copying and break out of the for loop
if (arr[i] == '\r'){
cout << endl;
nameSize=i; // storing the size of the name
break;
} // end if
cout << arr[i];
} // end for - Array arr
// Displaying Array
cout << endl;
for (i=0; i<nameSize; i++)
cout << arr[i];
return 0;
} // end main()