Simple Table or cursor move ?

Hi Guys,
I am new in c++ and I was wondering how to make similar to below example :


Your Name :__________Your Father Name :__________ Your Mother Name:__________
Your City :__________Your Birthday :__________ Your TEL Number :__________

How I can make the cursor move to the next field after I hit enter.(line is space)

Note : This is not Homework as i am not student. but trying to learn something new .

I think this might require learning a bit of the windows.h header, i dont have any knowledge of this but im sure one of the forum gods like duos would be happy to answer this!
@kail2012

Here is one way. You'll need to add an array, like string answer[6] and then use cin >> answer[x]; if you want to keep track of all the inputs.
Just ask if you need more clarification on how this program works.

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Filling a form.cpp : main project file.

#include "stdafx.h" // I use with MS Visual 2008 Express. Leave off if you use something different
#include <iostream>
#include <string>
#include <windows.h>

using namespace std;

HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;

void gotoXY(int, int);

int main()
{
	int location[6][2] = {{13,6},{41,6},{69,6},{13,8},{41,8},{25,10}},x,y,z;
// location array = groups of column, and row, for gotoXY()
	string form[6]={"your name","father's name","mother's name","city of birth","your birthdate","your phone number"}, answer;
// string form[] = allowing different text to be printed for instructions

	gotoXY(2,6); // locates 2nd column, sixth row
	cout << "Your Name :__________   Father's Name :__________    Mother's Name:__________";
	gotoXY(2,8);  // locates 2nd column, eigthth row
	cout << "Your City :__________   Your Birthday :__________";
	gotoXY(2,10);  // locates 2nd column, tenth row
	cout << "Your TELEPHONE Number :__________";

	for(x=0;x<6;x++)
	{
		gotoXY(16,15);
		cout << "Please enter, in space provided, " << form[x] << ". ";      
		y=location[x][0];
		z=location[x][1];
		gotoXY(y,z);
		cin >> answer;
	}
	gotoXY(19,21);
	cout << "Thank you for your assistance!!";
	gotoXY(19,23);
	return 0;
}

void gotoXY(int x, int y) 
{ 
CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition); 
}
@whitenite1
Thanks man, the idea is clear , but its not working in perfect way , i am using Dev-C .its compile . any way i will try to modify it .

first below should show in the screen

Your Name :__________Your Father Name :__________ Your Mother Name:__________
Your City :__________Your Birthday :__________ Your TEL Number :__________

and the cursor should blinking after the word (Your Name: - ) then i can move the cursor to next either by tab or by hitting enter so i can fill the requested .
Topic archived. No new replies allowed.