This is the problem. The program works in the first run. but after you enter a key and proceed for another entry, it skips the "LAST NAME:" line and directly asks for the "FIRST NAME" line. i can't find the problem in the code so...help! >.< (skip forms and frames code)
#include <iostream.h> //header files
#include <conio.h>
#include <cstring>
#include <stdlib>
#include <fstream> //header for fstreaming of files
void form(int, int, int, int, int, int); //for form
void frame(int, int, int, int, int, int);//for frame
void main(void)
{
char ans;
do{
clrscr();
form(3,3,10,10, YELLOW,BROWN);
gotoxy(14,4); cprintf("Girl Scouts of the Philippines Automated Registration Form");
gotoxy(4,9); cprintf("Please enter the information needed");
frame(2,2,79,37, LIGHTMAGENTA,WHITE); //size and color of the frame
frame(1,1,80,38,WHITE,LIGHTMAGENTA);
textbackground (CYAN);
gotoxy(2,2);cprintf("");
textbackground (CYAN);
gotoxy(2,3);cprintf("");
textbackground (CYAN);
gotoxy(2,4); cprintf("");
textbackground (CYAN);
gotoxy(2,5);cprintf("");
textbackground (CYAN);
gotoxy(2,6);cprintf("");
textbackground (CYAN);
gotoxy(2,7);cprintf("");
ofstream input;
input.open("GSP.xls");
if (input.good())
{
char last[60];
char first[60];
char middle[60];
char address[60];
char age[3];
char yrsec[15];
char bday[8];
input.open("GSP.xls");
textbackground (MAGENTA);
gotoxy(4,12); cprintf("Last Name: "); cin.getline(last,60); //for enabling whitespaces
input<<"Last Name: "<<last;
gotoxy(4,14); cprintf("First Name: "); cin.getline(first, 60);
input<<"First Name: "<<first;
gotoxy(4,16); cprintf("Middle Name: "); cin.getline(middle, 60);
input<<"Middle Name: "<<middle;
gotoxy(4,18); cprintf("Address: "); cin.getline(last,60);
input<<"Last Name: "<<address;
gotoxy(4,20); cprintf("Age: ");cin>>age;
input<<"Age :"<<age;
gotoxy(4,22); cprintf("Year-Section: "); cin>>yrsec;
input<<"Year-Section: "<<yrsec;
gotoxy(4,24); cprintf("Birthday [mm/dd/yy]: "); cin>>bday;
input<<"Birthday: "<<bday;
clrscr();
input.close();
}
gotoxy(4,8);cprintf("Note: If you want to see the entered information go to the folder");
gotoxy(4,9);cprintf("where the program is. You can also edit the information given.");
gotoxy(4,12);cprintf("Do you wish to input more files? [y/n] "); cin>>ans;
gotoxy(40,18);cprintf("");
frame(2,2,79,37, LIGHTMAGENTA,WHITE); //size and color of the frame
frame(1,1,80,38,WHITE,LIGHTMAGENTA);
input.close();
}while (ans=='y'||ans=='Y');
}
void form(int x1, int y1, int y2, int x2, int forecolor, int backcolor)
{
textcolor(forecolor); textbackground(backcolor);
for(int k = y1; k <= y2; k++)
for(int h = x1 ; h <= x2; h++)
{gotoxy(h,k); cprintf("");}
}
void frame(int x1, int y1, int x2, int y2, int color, int bgcolor)
{
textcolor(color);
textbackground(bgcolor);
for(int x = x1+1; x < x2; x++)
{
gotoxy(x,y1); cprintf("Ä");
gotoxy(x,y2); cprintf("Ä");
}
for (int y= y1+1; y < y2; y++)
{
gotoxy(x1,y); cprintf("³");
gotoxy(x2,y); cprintf("³");
}
gotoxy(x1,y1); cprintf("Ú");
gotoxy(x2,y1); cprintf("¿");
gotoxy(x1,y2); cprintf("À");
gotoxy(x2,y2); cprintf("À");
}