Hello.I have written this code below on how to enter basic data input for students. Unfortunately, spaces between the words I enter (in testing) cause errors in the program.
Here is the program:
//BASIC C++ Codes
//Francis Darwin Eugenio
#include <iostream.h>
#include <conio.h>
void main(void)
{
clrscr();
char name[25];
cout <<"\nEnter your Name (No Spaces):";cin>>name[25];
char yrandsec[20];
cout <<"\nEnter your Year and Section:";cin>>yrandsec;
int age[3];
cout <<"\nEnter your Age:";
cin>>age[3];
char birthday[20];
cout <<"\nEnter your Birthday:";cin>>birthday;
char address[50];
cout <<"\nEnter your Address:";cin>>address;
int tel[8];
cout <<"\nEnter you Telephone No:";
cin>>tel[8];
cout<<"\n\nName:"<<name;
cout<<"\nYr. and Sec:"<<yrandsec;
cout<<"\nAge="<<age;
cout<<"\n\Birthday:"<<birthday;
cout<<"\n\Address:"<<address;
cout<<"\nTelephone No.:"<<tel;
getch();
}
Here is the result when I type in the name "Yhelman Gultia"
Enter your Name (No Spaces):Yhelman Gultia
Enter your Year and Section:
Enter your Age:
Enter your Birthday:
Enter your Address:
Enter you Telephone No:
Name:É ↕
Yr. and Sec:helman
Age=0x0012ff30
Birthday:
Address:
Telephone No.:0x0012fec8
Any help is appreciated. Thank you.
PS.The problem can't be solved even if I replaced char with wchar_.