---
title: "Visual C++ och gotoxy()..."
type: "forum-thread"
url: "https://www.webforum.nu/amne/c-cpp/28027-visual-c-och-gotoxy"
topic: "C/C++"
topic_url: "https://www.webforum.nu/amne/c-cpp"
author: "Engine^"
published: "2000-12-14T13:42:00.000Z"
updated: "2001-03-04T20:13:00.000Z"
replies: 1
views: 425
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/c-cpp/28027-visual-c-och-gotoxy"
---

# Visual C++ och gotoxy()...

## #1 — Engine^, 2000-12-14T13:42Z

Vet nån hur man kan använda sig utav conio.h:s gotoxy()-funktioner för att placera text i en dos-applikation? Det fungerar bra i Borland, men inte i Visual och det är Visual jag helst använder.

Permalänk: https://www.webforum.nu/p/28027

## #2 — niels, 2001-03-04T20:13Z

Använd dig av följande följande header fil:

\<font size="1" face="Verdana, Arial, Helvetica, sans-serif"\>Kod:\<font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#666600"\>
\#ifndef CONSOL_H
\#define CONSOL_H

\#include \<windows.h\>

\#define SCROLL_POS 24

void Init_Consol(void);
inline void Set_Color(int fcolor, int bcolor);
inline void DrawString(int x, int y, char\* string);
inline void Clear_Screen(void);

CONSOLE_SCREEN_BUFFER_INFO con_info;
HANDLE hconsole;

void Init_Graphics(void)
{
	COORD console_size = {80,25};
	srand((unsigned)time(NULL));
	hconsole=CreateFile("CONOUT$",GENERIC_WRITE &#0124; GENERIC_READ,
		FILE_SHARE_READ &#0124; FILE_SHARE_WRITE,
		0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
	SetConsoleScreenBufferSize(hconsole,console_size);
	GetConsoleScreenBufferInfo(hconsole,&con_info);
}

inline void Set_Color(int fcolor, int bcolor=0)
{
	SetConsoleTextAttribute(hconsole,(WORD)((bcolor \<\< 4) &#0124; fcolor));
}

inline void Draw_String(int x, int y, char\* string)
{
	COORD cursor_pos;
	cursor_pos.X = x;
	cursor_pos.Y = y;
	SetConsoleCursorPosition(hconsole,cursor_pos);
	printf("%s",string);
}

inline void Clear_Screen(void)
{
	Set_Color(15,0);
	for(int index=0; index\<=25; index++)
	{
		Draw_String(0, SCROLL_POS, "\\n");
	}
}

\#endif

Innehåller functioner som man kan använda vid utveckling av consol program.

/Nisse

Permalänk: https://www.webforum.nu/p/400965

---

Tråden på webben: https://www.webforum.nu/amne/c-cpp/28027-visual-c-och-gotoxy
