C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-04-2009, 07:38 AM   #1
Registered User
 
Join Date: Nov 2009
Posts: 3
Exclamation Determining XY Coordinates

How can i determine the XY coordinates of a character and print the output on the screen and my text file?

would it be possible to use gotoxy?

for example:






void print(ifstream& input, ofstream& output);

void gotoxy(int x, int y);

void print(ifstream& input, ofstream& output)


{
int x, y;
COORD coord;
coord.X = x;
coord.Y = y;

...
...
...
jakevinraymundo is offline   Reply With Quote
Old 11-04-2009, 07:39 AM   #2
Registered User
 
Join Date: Nov 2009
Posts: 3
btw, i used the windows.h library.. are there any libraries that I could possibly use?
jakevinraymundo is offline   Reply With Quote
Old 11-04-2009, 07:43 AM   #3
3735928559
 
Join Date: Mar 2008
Posts: 693
i don't understand what you mean. by "determine the XY coordinates of a character"

do you mean the line and column number of a particular character in the console buffer or what?
m37h0d is offline   Reply With Quote
Old 11-04-2009, 08:13 AM   #4
Registered User
 
Join Date: Nov 2009
Posts: 3
by XY, I mean rows,columns

For example, you are given the following text file and you are to determine the coordinates of Xs..
XOOXOOXXOX
XOOXOOOOOX
XOXXOOOXOO

The output would be:

“The coordinates of the # signs are:
1,1/1,4/1,7/1,8/1,10
2,1/2,4/2,10
3,1/3,3/3,4/3,8"
jakevinraymundo is offline   Reply With Quote
Old 11-04-2009, 09:11 AM   #5
3735928559
 
Join Date: Mar 2008
Posts: 693
ok, so what are you confused about?
m37h0d is offline   Reply With Quote
Old 11-04-2009, 09:27 AM   #6
Registered User
 
Join Date: Jul 2009
Posts: 46
What code do you have that you can show us? For starters, try putting the contents of the text file into a 2D array and looping through that to find the X's.
crowe is offline   Reply With Quote
Old 11-04-2009, 09:34 AM   #7
3735928559
 
Join Date: Mar 2008
Posts: 693
that's probably not the best strategy imo.

i would read the file 1 character at a time, while maintaining column and row counters and push_back their current values onto a vector of coords whenever you find the needle in the haystack.

Last edited by m37h0d; 11-04-2009 at 09:37 AM.
m37h0d is offline   Reply With Quote
Reply

Tags
xy coordinates

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get relative mouse coordinates when GLUT return absolute joeprogrammer Game Programming 14 02-10-2009 06:35 PM
Adventures in labyrinth generation. guesst Game Programming 8 10-12-2008 01:30 PM
Global coordinates in OpenGL? IcyDeath C++ Programming 1 11-25-2004 06:29 PM
Converting from Screen to World Coordinates DavidP Game Programming 9 05-11-2004 12:51 PM
Size of 1 pixel ooosawaddee3 C++ Programming 4 07-26-2002 08:06 PM


All times are GMT -6. The time now is 09:28 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22