CIN problem..

hi, im still a beginner at c++..

thats my code.. i can still input in name, address, bdate, but when ill input in bplace and guardian the program will like go crazy.. i dont know why.. please help me thanks in advance..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <windows.h>
#include <string>

using namespace std;


void gotoxy(int x,int y)
{	
	COORD coord;
	coord.X=x; coord.Y=y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

main()
{
	int bdate;
	string name, address, bplace, guardian;
	
	gotoxy(5,5); cout << "Name: "; 
	gotoxy(5,6); cout << "Address: "; 
	gotoxy(5,7); cout << "Birth Date: ";
	gotoxy(5,8); cout << "Birth Place: "; 
	gotoxy(5,9); cout << "Guardian: ";
	gotoxy(11,5); cin >> name;
	gotoxy(14,6); cin >> address;
	gotoxy(17,7); cin >> bdate;
	gotoxy(18,8); cin >> bplace;
	gotoxy(15,9); cin >> guardian;

	cout <<endl << endl;
cin.get();
return 0;
}
	
Yes you can not enter string into integer and vice versa. i think that might causeing you trouble.
Last edited on
For me the code works without problems (dev-c++)
Topic archived. No new replies allowed.