tags:

views:

81

answers:

4

Hi,

Sorry about the dumb question, but is there a way to draw a character at a random place on the screen without using any "heavy" graphics libraries?

Thanks, Li

A: 

Assuming it's in console, 1 and 2

Drakosha
+3  A: 
HDC hdc = GetDC(NULL);
RECT rc;
rc.left = 0;
rc.right = 100;
rc.top = 0;
rc.bottom = 100;
DrawText(hdc, L"Bla", 3, &rc, 0);

Am I helping a virus programmer here?

kaptnole
No :) You're helping a poor computer science student :)
+3  A: 

Try writing directly to video RAM at address B800:0000 (see Bios Memory Map).

PP
Oh wow, this still works? I used to do that when writing Turbo Pascal programs on my 80286 :-)
Frerich Raabe
No, actually I was expected to get voted down: I'm feeling rather nostalgic today!
PP
You get one upvote for this. I laughed.
Calvin1602
+1  A: 

Assuming this is a console application:

#include "windows.h"

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

void PaintcharOnRandomLocation(const char c)
{
srand(0);
int x = rand(79);
int y = rand(24);
gotoxy(x,y);
putch(c);
}
rursw1
Thanks :) all work perfectly.