ERRORS. UNDECLARED IDENTIFIER.

How to change these into some code that runs in M.Visual Studio 6.0

Page 1 of 1

13 Replies - 2088 Views - Last Post: 11 March 2010 - 11:01 AM Rate Topic: -----

#1 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

ERRORS. UNDECLARED IDENTIFIER.

Posted 08 March 2010 - 03:13 AM

PLEASE OPEN THE ATTACHMENT... That is the code... try to compile it... This is for our project... and it is 40% of our final grade...I REALLY NEED YOUR HELP, PLEASE!!!THANK YOU VERY MUCH!!!

Here's the error

Compiling...
MAGIC.CPP
C:\Documents and Settings\minimum\Desktop\C++ proj\MAGIC.CPP(19) : error C2065: 'textcolor' : undeclared identifier
C:\Documents and Settings\minimum\Desktop\C++ proj\MAGIC.CPP(20) : error C2065: 'gotoxy' : undeclared identifier
C:\Documents and Settings\minimum\Desktop\C++ proj\MAGIC.CPP(21) : error C2065: 'delay' : undeclared identifier
C:\Documents and Settings\minimum\Desktop\C++ proj\MAGIC.CPP(166) : error C2065: 'random' : undeclared identifier
Error executing cl.exe.


here's the code..

//THE MAGICIAN
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <windows.h>
#include <winuser.h>
#include <windowsx.h>
main()
{

int x, x2=6, lo, di;
int x3=5, x4=3, x5=4;
char cho, col, col2, col3;
rand();
system("cls"); 
Sleep(2);
textcolor(15);
gotoxy(44,13);cprintf("X");
delay(100);
textcolor(0);
gotoxy(44,13);cprintf(" ");
textcolor(15);
gotoxy(42,13);cprintf("O");
delay(100);
textcolor(0);
gotoxy(42,13);cprintf(" ");
textcolor(15);
gotoxy(41,13);cprintf("C");
delay(100);
textcolor(0);
gotoxy(41,13);cprintf(" ");
textcolor(15);
gotoxy(40,13);cprintf("I");
delay(100);
textcolor(0);
gotoxy(40,13);cprintf(" ");
textcolor(15);
gotoxy(39,13);cprintf("R");
delay(100);
textcolor(0);
gotoxy(39,13);cprintf(" ");
textcolor(15);
gotoxy(38,13);cprintf("N");
delay(100);
textcolor(0);
gotoxy(38,13);cprintf(" ");
textcolor(15);
gotoxy(37,13);cprintf("E");
delay(100);
textcolor(0);
gotoxy(37,13);cprintf(" ");
delay(100);
textcolor(15);
gotoxy(37,13);cprintf("E");
delay(100);
textcolor(8);
gotoxy(37,13);cprintf("E");
textcolor(15);
gotoxy(38,13);cprintf("N");
delay(100);
textcolor(8);
gotoxy(38,13);cprintf("N");
textcolor(15);
gotoxy(39,13);cprintf("R");
delay(100);
textcolor(8);
gotoxy(39,13);cprintf("R");
textcolor(15);
gotoxy(40,13);cprintf("I");
delay(100);
textcolor(8);
gotoxy(40,13);cprintf("I");
textcolor(15);
gotoxy(41,13);cprintf("C");
delay(100);
textcolor(8);
gotoxy(41,13);cprintf("C");
textcolor(15);
gotoxy(42,13);cprintf("O");
delay(100);
textcolor(8);
gotoxy(42,13);cprintf("O");
textcolor(15);
gotoxy(44,13);cprintf("X");
delay(100);
textcolor(8);
gotoxy(44,13);cprintf("X");
Sleep(2);
system("cls"); 
textcolor(15);
gotoxy(35,13);cprintf("T");
delay(100);
gotoxy(36,13);cprintf("H");
textcolor(8);
gotoxy(35,13);cprintf("T");
delay(100);
gotoxy(36,13);cprintf("H");
textcolor(15);
gotoxy(37,13);cprintf("E");
delay(100);
gotoxy(39,13);cprintf("M");
textcolor(8);
gotoxy(37,13);cprintf("E");
delay(100);
gotoxy(39,13);cprintf("M");
textcolor(15);
gotoxy(40,13);cprintf("%c", x2);
delay(100);
gotoxy(41,13);cprintf("G");
textcolor(8);
gotoxy(40,13);cprintf("%c", x2);
delay(100);
gotoxy(41,13);cprintf("G");
textcolor(15);
gotoxy(42,13);cprintf("I");
delay(100);
gotoxy(43,13);cprintf("C");
textcolor(8);
gotoxy(42,13);cprintf("I");
delay(100);
gotoxy(43,13);cprintf("C");
textcolor(15);
gotoxy(44,13);cprintf("I");
delay(100);
gotoxy(45,13);cprintf("%c", x3);
textcolor(8);
gotoxy(44,13);cprintf("I");
delay(100);
gotoxy(45,13);cprintf("%c", x3);
textcolor(15);
gotoxy(46,13);cprintf("N");
delay(100);
textcolor(8);
gotoxy(46,13);cprintf("N");
delay(100);
gotoxy(35,13);cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
gotoxy(39,13);cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
delay(100);
cprintf(" ");
Sleep(2);
system("cls"); 
for(x=1; x<=50; x++)
  {
  textcolor(8);
  gotoxy(random(80), random(25));cprintf("%c", x2);
  delay(10);
  gotoxy(random(80), random(25));cprintf("%c", x3);
  delay(10);
  textcolor(4);
  gotoxy(random(80), random(25));cprintf("%c", x4);
  delay(10);
  gotoxy(random(80), random(25));cprintf("%c", x5);
  delay(10);
  }
intro:
system("cls"); 
textcolor(8);
gotoxy(1,1);cprintf(" nter");
gotoxy(73,25);cprintf(" redits");
gotoxy(68,1);cprintf("THE M%cGICI%cN", x2, x3);
gotoxy(1,25);cprintf("Best viewed in maximize window");
textcolor(15);
gotoxy(1,1);cprintf("E");
gotoxy(73,25);cprintf("C");
cho=getch();

if(cho=='e' || cho=='E')
{
system("cls"); 
for(lo=28; lo<=53; lo++)
  {
  textcolor(8);
  gotoxy(lo,14);cprintf("ÛÛ");
  }

for(lo=0, di=28; lo<=100; lo+=4, di++)
  {
  textcolor(15);
  gotoxy(28,12);cprintf("initializing trick...");
  gotoxy(28,13);cprintf("%d%", lo);
  gotoxy(di,14);cprintf("ÛÛ");
  delay(200);
  }
Sleep(2);
refresh:
system("cls");
textcolor(8);
gotoxy(35,1);cprintf("THE M%cGICI%cN", x2, x3);
textcolor(15);
gotoxy(27,2);cprintf("ÚÄÄÄÄÄÄ¿");
gotoxy(27,3);cprintf("³      ³");
gotoxy(27,4);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,5);cprintf("³      ³");
gotoxy(27,6);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,7);cprintf("³      ³");
gotoxy(27,8);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,9);cprintf("³      ³");
gotoxy(27,10);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,11);cprintf("³      ³");
gotoxy(27,12);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,13);cprintf("³      ³");
gotoxy(27,14);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(27,15);cprintf("³      ³");
gotoxy(27,16);cprintf("³      ³");
gotoxy(27,17);cprintf("³      ³");
gotoxy(27,18);cprintf("ÀÄÄÄÄÄÄÙ");

gotoxy(37,2);cprintf("ÚÄÄÄÄÄÄ¿");
gotoxy(37,3);cprintf("³      ³");
gotoxy(37,4);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,5);cprintf("³      ³");
gotoxy(37,6);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,7);cprintf("³      ³");
gotoxy(37,8);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,9);cprintf("³      ³");
gotoxy(37,10);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,11);cprintf("³      ³");
gotoxy(37,12);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,13);cprintf("³      ³");
gotoxy(37,14);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(37,15);cprintf("³      ³");
gotoxy(37,16);cprintf("³      ³");
gotoxy(37,17);cprintf("³      ³");
gotoxy(37,18);cprintf("ÀÄÄÄÄÄÄÙ");

gotoxy(47,2);cprintf("ÚÄÄÄÄÄÄ¿");
gotoxy(47,3);cprintf("³      ³");
gotoxy(47,4);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,5);cprintf("³      ³");
gotoxy(47,6);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,7);cprintf("³      ³");
gotoxy(47,8);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,9);cprintf("³      ³");
gotoxy(47,10);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,11);cprintf("³      ³");
gotoxy(47,12);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,13);cprintf("³      ³");
gotoxy(47,14);cprintf("ÃÄÄÄÄÄÄ´");
gotoxy(47,15);cprintf("³      ³");
gotoxy(47,16);cprintf("³      ³");
gotoxy(47,17);cprintf("³      ³");
gotoxy(47,18);cprintf("ÀÄÄÄÄÄÄÙ");
textcolor(8);
gotoxy(1,25);cprintf(" efresh");
textcolor(15);
gotoxy(1,25);cprintf("R");
gotoxy(35,20);cprintf("Pick a card!");
gotoxy(32,21);cprintf("Enter which column!");
textcolor(7);
gotoxy(33,17);cprintf("1");
gotoxy(43,17);cprintf("2");
gotoxy(53,17);cprintf("3");

textcolor(4);
x=3;
gotoxy(28,3);cprintf("K%c", x);
gotoxy(28,7);cprintf("3%c", x);
gotoxy(28,9);cprintf("Q%c", x);
gotoxy(28,11);cprintf("6%c", x);
gotoxy(28,13);cprintf("J%c", x);
gotoxy(28,15);cprintf("9%c", x);
textcolor(8);
x=5;
gotoxy(48,7);cprintf("A%c", x2);
gotoxy(28,5);cprintf("4%c", x2);
gotoxy(38,3);cprintf("2%c", x);
gotoxy(38,5);cprintf("J%c", x);
gotoxy(38,7);cprintf("K%c", x);
gotoxy(38,9);cprintf("8%c", x);
gotoxy(38,13);cprintf("3%c", x);
gotoxy(38,15);cprintf("5%c", x);

textcolor(4);
x=4;
gotoxy(38,11);cprintf("7%c", x);
gotoxy(48,3);cprintf("2%c", x);
gotoxy(48,5);cprintf("9%c", x);
gotoxy(48,9);cprintf("J%c", x);
gotoxy(48,11);cprintf("Q%c", x);
gotoxy(48,13);cprintf("5%c", x);
gotoxy(48,15);cprintf("6%c", x);
back:
col=getch();
if(col=='1')
  {
  textcolor(8);
  gotoxy(33,23);cprintf("shuffling cards...");
  Sleep(2);
  textcolor(15);
  gotoxy(35,20);cprintf("Where is it?");
  gotoxy(33,23);cprintf("                  ");
  textcolor(4);
  x=4;
  gotoxy(28,15);cprintf("7%c", x);
  gotoxy(28,3);cprintf("2%c", x);
  gotoxy(38,3);cprintf("9%c", x);
  gotoxy(28,5);cprintf("J%c", x);
  gotoxy(38,5);cprintf("Q%c", x);
  gotoxy(48,5);cprintf("5%c", x);
  gotoxy(28,7);cprintf("6%c", x);

  textcolor(4);
  x=3;
  gotoxy(38,7);cprintf("K%c", x);
  gotoxy(28,9);cprintf("3%c", x);
  gotoxy(38,9);cprintf("Q%c", x);
  gotoxy(48,9);cprintf("6%c", x);
  gotoxy(28,11);cprintf("J%c", x);
  gotoxy(38,11);cprintf("9%c", x);

  textcolor(8);
  x=5;
  gotoxy(48,3);cprintf("A%c", x2);
  gotoxy(48,7);cprintf("4%c", x2);
  gotoxy(48,11);cprintf("2%c", x);
  gotoxy(28,13);cprintf("J%c", x);
  gotoxy(38,13);cprintf("K%c", x);
  gotoxy(48,13);cprintf("8%c", x);
  gotoxy(38,15);cprintf("3%c", x);
  gotoxy(48,15);cprintf("5%c", x);
  back2:
  col2=getch();

  if(col2=='1')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(38,11);cprintf("7%c", x);
    gotoxy(38,7);cprintf("2%c", x);
    gotoxy(48,11);cprintf("9%c", x);
    gotoxy(48,7);cprintf("J%c", x);
    gotoxy(28,13);cprintf("Q%c", x);
    gotoxy(38,3);cprintf("5%c", x);
    gotoxy(28,9);cprintf("6%c", x);

    textcolor(4);
    x=3;
    gotoxy(38,13);cprintf("K%c", x);
    gotoxy(38,9);cprintf("3%c", x);
    gotoxy(48,13);cprintf("Q%c", x);
    gotoxy(28,5);cprintf("6%c", x);
    gotoxy(48,9);cprintf("J%c", x);
    gotoxy(28,15);cprintf("9%c", x);

    textcolor(8);
    x=5;
    gotoxy(28,3);cprintf("A%c", x2);
    gotoxy(48,3);cprintf("4%c", x2);
    gotoxy(38,5);cprintf("2%c", x);
    gotoxy(28,11);cprintf("J%c", x);
    gotoxy(38,15);cprintf("K%c", x);
    gotoxy(48,5);cprintf("8%c", x);
    gotoxy(48,15);cprintf("3%c", x);
    gotoxy(28,7);cprintf("5%c", x);
    back3:
    col3=getch();

    if(col3=='2')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("3%c", x);
      }
    else if(col3=='3')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("J%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else
      goto back3;
    }
  else if(col2=='2')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(48,15);cprintf("7%c", x);
    gotoxy(48,11);cprintf("2%c", x);
    gotoxy(38,7);cprintf("9%c", x);
    gotoxy(28,13);cprintf("J%c", x);
    gotoxy(48,7);cprintf("Q%c", x);
    gotoxy(38,3);cprintf("5%c", x);
    gotoxy(38,13);cprintf("6%c", x);

    textcolor(4);
    x=3;
    gotoxy(28,9);cprintf("K%c", x);
    gotoxy(48,13);cprintf("3%c", x);
    gotoxy(38,9);cprintf("Q%c", x);
    gotoxy(28,5);cprintf("6%c", x);
    gotoxy(28,15);cprintf("J%c", x);
    gotoxy(48,9);cprintf("9%c", x);

    textcolor(8);
    x=5;
    gotoxy(28,3);cprintf("A%c", x2);
    gotoxy(48,3);cprintf("4%c", x2);
    gotoxy(38,5);cprintf("2%c", x);
    gotoxy(38,15);cprintf("J%c", x);
    gotoxy(28,11);cprintf("K%c", x);
    gotoxy(48,5);cprintf("8%c", x);
    gotoxy(38,11);cprintf("3%c", x);
    gotoxy(28,7);cprintf("5%c", x);
    back4:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("K%c", x);
      }
    else if(col3=='2')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("Q%c", x);
      }
    else if(col3=='3')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("9%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else
      goto back4;
    }
  else if(col2=='3')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(48,15);cprintf("7%c", x);
    gotoxy(48,11);cprintf("2%c", x);
    gotoxy(28,3);cprintf("9%c", x);
    gotoxy(28,13);cprintf("J%c", x);
    gotoxy(38,3);cprintf("Q%c", x);
    gotoxy(48,7);cprintf("5%c", x);
    gotoxy(38,13);cprintf("6%c", x);

    textcolor(4);
    x=3;
    gotoxy(48,3);cprintf("K%c", x);
    gotoxy(48,13);cprintf("3%c", x);
    gotoxy(28,5);cprintf("Q%c", x);
    gotoxy(38,9);cprintf("6%c", x);
    gotoxy(28,15);cprintf("J%c", x);
    gotoxy(38,5);cprintf("9%c", x);

    textcolor(8);
    x=5;
    gotoxy(38,7);cprintf("A%c", x2);
    gotoxy(28,9);cprintf("4%c", x2);
    gotoxy(48,9);cprintf("2%c", x);
    gotoxy(38,15);cprintf("J%c", x);
    gotoxy(48,5);cprintf("K%c", x);
    gotoxy(28,11);cprintf("8%c", x);
    gotoxy(28,7);cprintf("3%c", x);
    gotoxy(38,11);cprintf("5%c", x);
    back5:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("4%c", x2);
      }
    else if(col3=='2')
      {
      system("cls");
      x=3;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("6%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else
      goto back5;
    }
  else if(col2=='r' || col2=='R')
    goto refresh;
  else
    goto back2;
  }
else if(col=='2')
  {
  textcolor(8);
  gotoxy(33,23);cprintf("shuffling cards...");
  Sleep(2);
  textcolor(15);
  gotoxy(35,20);cprintf("Where is it?");
  gotoxy(33,23);cprintf("                  ");
  textcolor(4);
  x=4;
  gotoxy(48,9);cprintf("7%c", x);
  gotoxy(28,3);cprintf("2%c", x);
  gotoxy(38,3);cprintf("9%c", x);
  gotoxy(28,5);cprintf("J%c", x);
  gotoxy(38,5);cprintf("Q%c", x);
  gotoxy(48,5);cprintf("5%c", x);
  gotoxy(28,7);cprintf("6%c", x);

  textcolor(8);
  x=5;
  gotoxy(48,3);cprintf("A%c", x2);
  gotoxy(28,13);cprintf("4%c", x2);
  gotoxy(38,7);cprintf("2%c", x);
  gotoxy(48,7);cprintf("J%c", x);
  gotoxy(28,9);cprintf("K%c", x);
  gotoxy(38,9);cprintf("8%c", x);
  gotoxy(28,11);cprintf("3%c", x);
  gotoxy(38,11);cprintf("5%c", x);

  textcolor(4);
  x=3;
  gotoxy(48,11);cprintf("K%c", x);
  gotoxy(38,13);cprintf("3%c", x);
  gotoxy(48,13);cprintf("Q%c", x);
  gotoxy(28,15);cprintf("6%c", x);
  gotoxy(38,15);cprintf("J%c", x);
  gotoxy(48,15);cprintf("9%c", x);
  back6:
  col2=getch();

  if(col2=='1')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(28,5);cprintf("7%c", x);
    gotoxy(38,7);cprintf("2%c", x);
    gotoxy(48,11);cprintf("9%c", x);
    gotoxy(48,7);cprintf("J%c", x);
    gotoxy(28,13);cprintf("Q%c", x);
    gotoxy(38,3);cprintf("5%c", x);
    gotoxy(28,9);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(28,3);cprintf("A%c", x2);
    gotoxy(28,11);cprintf("4%c", x2);
    gotoxy(38,13);cprintf("2%c", x);
    gotoxy(48,3);cprintf("J%c", x);
    gotoxy(38,9);cprintf("K%c", x);
    gotoxy(48,13);cprintf("8%c", x);
    gotoxy(48,9);cprintf("3%c", x);
    gotoxy(28,15);cprintf("5%c", x);

    textcolor(4);
    x=3;
    gotoxy(38,5);cprintf("K%c", x);
    gotoxy(38,15);cprintf("3%c", x);
    gotoxy(48,5);cprintf("Q%c", x);
    gotoxy(38,11);cprintf("6%c", x);
    gotoxy(48,15);cprintf("J%c", x);
    gotoxy(28,7);cprintf("9%c", x);
    back7:
    col3=getch();

    if(col3=='2')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("K%c", x);
      }
    else if(col3=='3')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("3%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else goto back7;
    }
  else if(col2=='2')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(28,5);cprintf("7%c", x);
    gotoxy(48,11);cprintf("2%c", x);
    gotoxy(38,7);cprintf("9%c", x);
    gotoxy(28,13);cprintf("J%c", x);
    gotoxy(48,7);cprintf("Q%c", x);
    gotoxy(38,3);cprintf("5%c", x);
    gotoxy(38,13);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(28,3);cprintf("A%c", x2);
    gotoxy(38,15);cprintf("4%c", x2);
    gotoxy(28,9);cprintf("2%c", x);
    gotoxy(48,3);cprintf("J%c", x);
    gotoxy(48,13);cprintf("K%c", x);
    gotoxy(38,9);cprintf("8%c", x);
    gotoxy(28,15);cprintf("3%c", x);
    gotoxy(48,9);cprintf("5%c", x);

    textcolor(4);
    x=3;
    gotoxy(38,5);cprintf("K%c", x);
    gotoxy(28,11);cprintf("3%c", x);
    gotoxy(48,5);cprintf("Q%c", x);
    gotoxy(48,15);cprintf("6%c", x);
    gotoxy(38,11);cprintf("J%c", x);
    gotoxy(28,7);cprintf("9%c", x);
    back8:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("2%c", x);
      }
    else if(col3=='2')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is an");
      gotoxy(49,13);cprintf("!");
      textcolor(8);
      gotoxy(47,13);cprintf("8%c", x);
      }
    else if(col3=='3')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("5%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else goto back8;
    }
  else if(col2=='3')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=4;
    gotoxy(38,9);cprintf("7%c", x);
    gotoxy(48,11);cprintf("2%c", x);
    gotoxy(28,3);cprintf("9%c", x);
    gotoxy(28,13);cprintf("J%c", x);
    gotoxy(38,3);cprintf("Q%c", x);
    gotoxy(48,7);cprintf("5%c", x);
    gotoxy(38,13);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(38,7);cprintf("A%c", x2);
    gotoxy(38,15);cprintf("4%c", x2);
    gotoxy(48,3);cprintf("2%c", x);
    gotoxy(28,9);cprintf("J%c", x);
    gotoxy(48,13);cprintf("K%c", x);
    gotoxy(28,5);cprintf("8%c", x);
    gotoxy(28,15);cprintf("3%c", x);
    gotoxy(38,5);cprintf("5%c", x);

    textcolor(4);
    x=3;
    gotoxy(48,9);cprintf("K%c", x);
    gotoxy(48,5);cprintf("3%c", x);
    gotoxy(28,11);cprintf("Q%c", x);
    gotoxy(48,15);cprintf("6%c", x);
    gotoxy(28,7);cprintf("J%c", x);
    gotoxy(38,11);cprintf("9%c", x);
    back9:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(8);
      gotoxy(46,13);cprintf("J%c", x);
      }
    else if(col3=='2')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("7%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else goto back9;
    }
  else if(col2=='r' || col2=='R')
    goto refresh;
  else goto back6;
  }
else if(col=='3')
  {
  textcolor(8);
  gotoxy(33,23);cprintf("shuffling cards...");
  Sleep(2);
  textcolor(15);
  gotoxy(35,20);cprintf("Where is it?");
  gotoxy(33,23);cprintf("                  ");
  textcolor(4);
  x=3;
  gotoxy(28,3);cprintf("K%c", x);
  gotoxy(48,3);cprintf("3%c", x);
  gotoxy(28,5);cprintf("Q%c", x);
  gotoxy(38,5);cprintf("6%c", x);
  gotoxy(48,5);cprintf("J%c", x);
  gotoxy(28,7);cprintf("9%c", x);

  textcolor(4);
  x=4;
  gotoxy(28,15);cprintf("7%c", x);
  gotoxy(38,7);cprintf("2%c", x);
  gotoxy(48,7);cprintf("9%c", x);
  gotoxy(38,9);cprintf("J%c", x);
  gotoxy(48,9);cprintf("Q%c", x);
  gotoxy(28,11);cprintf("5%c", x);
  gotoxy(38,11);cprintf("6%c", x);

  textcolor(8);
  x=5;
  gotoxy(28,9);cprintf("A%c", x2);
  gotoxy(38,3);cprintf("4%c", x2);
  gotoxy(48,11);cprintf("2%c", x);
  gotoxy(28,13);cprintf("J%c", x);
  gotoxy(38,13);cprintf("K%c", x);
  gotoxy(48,13);cprintf("8%c", x);
  gotoxy(38,15);cprintf("3%c", x);
  gotoxy(48,15);cprintf("5%c", x);
  back10:
  col2=getch();

  if(col2=='1')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=3;
    gotoxy(38,7);cprintf("K%c", x);
    gotoxy(28,3);cprintf("3%c", x);
    gotoxy(48,7);cprintf("Q%c", x);
    gotoxy(28,13);cprintf("6%c", x);
    gotoxy(38,3);cprintf("J%c", x);
    gotoxy(28,9);cprintf("9%c", x);

    textcolor(4);
    x=4;
    gotoxy(38,11);cprintf("7%c", x);
    gotoxy(38,13);cprintf("2%c", x);
    gotoxy(48,3);cprintf("9%c", x);
    gotoxy(48,13);cprintf("J%c", x);
    gotoxy(28,5);cprintf("Q%c", x);
    gotoxy(48,9);cprintf("5%c", x);
    gotoxy(28,15);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(38,9);cprintf("A%c", x2);
    gotoxy(48,11);cprintf("4%c", x2);
    gotoxy(38,5);cprintf("2%c", x);
    gotoxy(28,11);cprintf("J%c", x);
    gotoxy(38,15);cprintf("K%c", x);
    gotoxy(48,5);cprintf("8%c", x);
    gotoxy(48,15);cprintf("3%c", x);
    gotoxy(28,7);cprintf("5%c", x);
    back11:
    col3=getch();

    if(col3=='2')
      {
      system("cls");
      x=5;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is an");
      gotoxy(49,13);cprintf("!");
      textcolor(8);
      gotoxy(47,13);cprintf("A%c", x2);
      }
    else if(col3=='3')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("5%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else goto back11;
    }
  else if(col2=='2')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=3;
    gotoxy(48,11);cprintf("K%c", x);
    gotoxy(28,3);cprintf("3%c", x);
    gotoxy(28,13);cprintf("Q%c", x);
    gotoxy(48,7);cprintf("6%c", x);
    gotoxy(38,3);cprintf("J%c", x);
    gotoxy(38,13);cprintf("9%c", x);

    textcolor(4);
    x=4;
    gotoxy(48,15);cprintf("7%c", x);
    gotoxy(28,9);cprintf("2%c", x);
    gotoxy(48,3);cprintf("9%c", x);
    gotoxy(38,9);cprintf("J%c", x);
    gotoxy(28,5);cprintf("Q%c", x);
    gotoxy(28,15);cprintf("5%c", x);
    gotoxy(48,9);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(48,13);cprintf("A%c", x2);
    gotoxy(38,7);cprintf("4%c", x2);
    gotoxy(38,5);cprintf("2%c", x);
    gotoxy(38,15);cprintf("J%c", x);
    gotoxy(28,11);cprintf("K%c", x);
    gotoxy(48,5);cprintf("8%c", x);
    gotoxy(38,11);cprintf("3%c", x);
    gotoxy(28,7);cprintf("5%c", x);
    back12:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("2%c", x);
      }
    else if(col3=='2')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("J%c", x);
      }
    else if(col3=='3')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("6%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else
      goto back12;
    }
  else if(col2=='3')
    {
    textcolor(8);
    gotoxy(33,23);cprintf("shuffling cards...");
    Sleep(2);
    textcolor(15);
    gotoxy(35,20);cprintf("Where is it?");
    gotoxy(33,23);cprintf("                  ");
    textcolor(4);
    x=3;
    gotoxy(48,11);cprintf("K%c", x);
    gotoxy(38,7);cprintf("3%c", x);
    gotoxy(28,13);cprintf("Q%c", x);
    gotoxy(38,3);cprintf("6%c", x);
    gotoxy(48,7);cprintf("J%c", x);
    gotoxy(38,13);cprintf("9%c", x);

    textcolor(4);
    x=4;
    gotoxy(48,15);cprintf("7%c", x);
    gotoxy(48,3);cprintf("2%c", x);
    gotoxy(28,9);cprintf("9%c", x);
    gotoxy(28,5);cprintf("J%c", x);
    gotoxy(38,9);cprintf("Q%c", x);
    gotoxy(28,15);cprintf("5%c", x);
    gotoxy(38,5);cprintf("6%c", x);

    textcolor(8);
    x=5;
    gotoxy(48,13);cprintf("A%c", x2);
    gotoxy(28,3);cprintf("4%c", x2);
    gotoxy(48,9);cprintf("2%c", x);
    gotoxy(38,15);cprintf("J%c", x);
    gotoxy(48,5);cprintf("K%c", x);
    gotoxy(28,11);cprintf("8%c", x);
    gotoxy(28,7);cprintf("3%c", x);
    gotoxy(38,11);cprintf("5%c", x);
    back13:
    col3=getch();

    if(col3=='1')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("9%c", x);
      }
    else if(col3=='2')
      {
      system("cls");
      x=4;
      textcolor(15);
      gotoxy(31,13);cprintf("Your card is a");
      gotoxy(48,13);cprintf("!");
      textcolor(4);
      gotoxy(46,13);cprintf("Q%c", x);
      }
    else if(col3=='r' || col3=='R')
      goto refresh;
    else
      goto back13;
    }
  else if(col2=='r' || col2=='R')
    goto refresh;
  else
    goto back10;
  }
else if(col=='r' || col=='R')
  goto refresh;
else
  goto back;
Sleep(2);
system("cls");
textcolor(4);
gotoxy(37,13);cprintf("THE END!");
}
else if(cho=='c' || cho=='C')
  {
  system("cls");
  textcolor(8);
  gotoxy(1,1);cprintf(" rogrammer:  nrico  orenzo");
  gotoxy(1,3);cprintf(" pecial thanks to:  ade  uliano");
  gotoxy(1,5);cprintf(" nspired by:  afael  artin's magic");
  gotoxy(1,25);cprintf(" ress any key to exit");
  textcolor(15);
  gotoxy(1,1);cprintf("P");
  gotoxy(13,1);cprintf("E");
  gotoxy(20,1);cprintf("L");
  gotoxy(1,3);cprintf("S");
  gotoxy(20,3);cprintf("J");
  gotoxy(25,3);cprintf("J");
  gotoxy(1,5);cprintf("I");
  gotoxy(14,5);cprintf("R");
  gotoxy(21,5);cprintf("M");
  gotoxy(1,25);cprintf("P");
  gotoxy(22,25);cprintf("...");
  getch();
  goto intro;
  }
else
  goto intro;
return 0;
}





I JUST NEED TO KNOW HOW TO CHANGE THE RANDOM,TEXTCOLOR, DELAY AND GOTOXY into something that runs in the MICROSOFT VISUAL STUDIO 6.0... tnx

Attached File(s)

  • Attached File  magic.txt (26.85K)
    Number of downloads: 108

This post has been edited by narusasutobi: 08 March 2010 - 03:36 AM


Is This A Good Question/Topic? 0
  • +

Replies To: ERRORS. UNDECLARED IDENTIFIER.

#2 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 999
  • View blog
  • Posts: 4,177
  • Joined: 14-February 08

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 08 March 2010 - 04:17 AM

Your problem is that Random, TextColor, Delay and GotoXY are functions which have not been declared or defined, maybe these functions reside inside that windowsx.h which is antiquiated.

Why don't you have a look for these functions in that header and see what they do, there may be newer ways of achieving what you want. By the way, what is this program supposed to do?
Was This Post Helpful? 1
  • +
  • -

#3 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 09:43 AM

its a card trick... i do not make these codes.. it was given to me by a friend.. someone says that it is only running in DOS.. actually i edit it before posting it the original have more errors... i need to know the conversion of code like gotoxy fro DOS to M.Visual Studio 6.0
Was This Post Helpful? 0
  • +
  • -

#4 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 09:48 AM

Here you will find the "textcolor" and "gotoxy" reimplemented, to work on 'new' Compilers, like MSVC 6.0: http://www.dreaminco...snippet921.htm.

For delay, you could use:
Sleep(miliseconds);


Where miliseconds is an integer, representing the miliseconds to "sleep".

For "random", use rand(). Example: if you have :
random(30);


it's equivalent would be:
rand() % 30;


Take a look here: http://www.cplusplus...y/cstdlib/rand/

This post has been edited by sarmanu: 09 March 2010 - 09:50 AM

Was This Post Helpful? 1
  • +
  • -

#5 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 10:30 AM

I dont understand the concept of textcolor...
it is now my only problem. please help me on this... btw.. thanks for the help.. i really appreciate it..

This post has been edited by narusasutobi: 09 March 2010 - 10:33 AM

Was This Post Helpful? 0
  • +
  • -

#6 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 10:37 AM

Here's an implementation of "textcolor", using SetConsoleTextAttribute:
#include <iostream>
#include <windows.h>

// Color codes, self explanatory color name.
// L_ prefix stands for 'light' (or bright)
enum ColorTable
{
	BLACK,
	BLUE,
	GREEN,
	AQUA,
	RED,
	PURPLE,
	YELLOW,
	WHITE,
	GRAY,
	L_BLUE,
	L_GREEN,
	L_AQUA,
	L_RED,
	L_PURPLE,
	L_YELLOW,
	L_WHITE
};

void textcolor(ColorTable color)
{
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(hConsole, color);
}

int main()
{
        // Sets text color to L_BLUE
	textcolor(L_BLUE);
	std::cout << "Hello!" << std::endl;

        // can explicitely call like this:
        textcolor(static_cast<ColorTable>(12));

	return 0;
}


So, if you implement my function, "textcolor(15)" would be:
textcolor(static_cast<ColorTable>(15));


More on SetConsoleTextAttribute: http://msdn.microsof...28VS.85%29.aspx
Was This Post Helpful? 1
  • +
  • -

#7 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 10:51 AM

IS THIS RIGHT?


#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <windows.h>
#include <winuser.h>
#include <windowsx.h>

void ConPrint(char *CharBuffer, int len);
void ConPrintAt(int x, int y, char *CharBuffer, int len);
void gotoxy(int x, int y);
// Color codes, self explanatory color name.
// L_ prefix stands for 'light' (or bright)
enum ColorTable
{
        BLACK,
        BLUE,
        GREEN,
        AQUA,
        RED,
        PURPLE,
        YELLOW,
        WHITE,
        GRAY,
        L_BLUE,
        L_GREEN,
        L_AQUA,
        L_RED,
        L_PURPLE,
        L_YELLOW,
        L_WHITE
};

void textcolor(ColorTable color)
{
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleTextAttribute(hConsole, color);
}

main()
{

int x, x2=6, lo, di;
int x3=5, x4=3, x5=4;
char cho, col, col2, col3;
rand();
system("cls"); 
Sleep(2);
textcolor(static_cast<ColorTable>(15));
gotoxy(44,13);cprintf("X");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(44,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));


IS THAT RIGHT?? The TEXTCOLOR and GOTOXY??

This post has been edited by narusasutobi: 09 March 2010 - 10:50 AM

Was This Post Helpful? 0
  • +
  • -

#8 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 10:54 AM

You didn't implement "gotoxy" anywhere. Anyways, here:
textcolor(static_cast<ColorTable>(0));


will set the text color to black. If your console screen color is black, then you won't see anything ...

Also:
rand();


Makes no sense ... you need to asign it to a variable:
int a = rand() % 3; // assigns to a, a randomized value between 0 and 2



EDIT: use "int main()", not main(). This is an integer function, and should be treated as such ...

This post has been edited by sarmanu: 09 March 2010 - 10:55 AM

Was This Post Helpful? 1
  • +
  • -

#9 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 11:02 AM

Is this okay?? HOW CAN I RESOLVE THE PROBLEMS IN GOTOXY?? thanks so much


#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <windows.h>
#include <winuser.h>
#include <windowsx.h>

void ConPrint(char *CharBuffer, int len);
void ConPrintAt(int x, int y, char *CharBuffer, int len);
void gotoxy(int x, int y);
// Color codes, self explanatory color name.
// L_ prefix stands for 'light' (or bright)
enum ColorTable
{
        BLACK,
        BLUE,
        GREEN,
        AQUA,
        RED,
        PURPLE,
        YELLOW,
        WHITE,
        GRAY,
        L_BLUE,
        L_GREEN,
        L_AQUA,
        L_RED,
        L_PURPLE,
        L_YELLOW,
        L_WHITE
};

void textcolor(ColorTable color)
{
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleTextAttribute(hConsole, color);
}

int main()
{

int x, x2=6, lo, di;
int x3=5, x4=3, x5=4;
char cho, col, col2, col3;
int a = rand() % 3; // assigns to a, a randomized value between 0 and 2
system("cls"); 
Sleep(2);
textcolor(static_cast<ColorTable>(15));
gotoxy(44,13);cprintf("X");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(44,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(42,13);cprintf("O");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(42,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(41,13);cprintf("C");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(41,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(40,13);cprintf("I");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(40,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));

Was This Post Helpful? 0
  • +
  • -

#10 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 11:05 AM

You didn't implement the gotoxy function. Try this:
void gotoxy(int x, int y)
{
   COORD coord;
   coord.X = x;
   coord.Y = y;

   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}


Was This Post Helpful? 1
  • +
  • -

#11 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 11:10 AM

I removed this
void ConPrint(char *CharBuffer, int len);
void ConPrintAt(int x, int y, char *CharBuffer, int len);
void gotoxy(int x, int y);


and replaced this...

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

   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}



It is like this now:


#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <windows.h>
#include <winuser.h>
#include <windowsx.h>

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

   SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

// Color codes, self explanatory color name.
// L_ prefix stands for 'light' (or bright)
enum ColorTable
{
        BLACK,
        BLUE,
        GREEN,
        AQUA,
        RED,
        PURPLE,
        YELLOW,
        WHITE,
        GRAY,
        L_BLUE,
        L_GREEN,
        L_AQUA,
        L_RED,
        L_PURPLE,
        L_YELLOW,
        L_WHITE
};

void textcolor(ColorTable color)
{
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        SetConsoleTextAttribute(hConsole, color);
}

int main()
{

int x, x2=6, lo, di;
int x3=5, x4=3, x5=4;
char cho, col, col2, col3;
int a = rand() % 3; // assigns to a, a randomized value between 0 and 2
system("cls"); 
Sleep(2);
textcolor(static_cast<ColorTable>(15));
gotoxy(44,13);cprintf("X");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(44,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(42,13);cprintf("O");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(42,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(41,13);cprintf("C");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(41,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(40,13);cprintf("I");
Sleep(100);
textcolor(static_cast<ColorTable>(0));
gotoxy(40,13);cprintf(" ");
textcolor(static_cast<ColorTable>(15));
gotoxy(39,13);cprintf("R");
Sleep(100);


I'm not finish yet in text color...
i'll finish it tomorrow after my class.
i gotta go to sleep now.. its already 2:10 am and im going to wake up 5:00 am....
THANK YOU VERY MUCH.. U R SO GREAT.. I HOPE YOU CAN HELP ME MORE...
Was This Post Helpful? 0
  • +
  • -

#12 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 09 March 2010 - 11:16 AM

About rand(): this function returns a randomized value. But if you don't call the function srand(seed), then you will get the same randomized numbers, at every runtime. Generally, this function's parameter is time(0) (with each second, time(0) returns a different value). You have to use:
#include <ctime>


to use time. Call srand() like this:
srand(unsigned(time(0))); 
// or
srand(unsigned(time(NULL)));


Be careful, you have to call this function ONLY once (preferably at the start of your main() function).
More on srand: http://www.cplusplus.../cstdlib/srand/

This post has been edited by sarmanu: 09 March 2010 - 11:16 AM

Was This Post Helpful? 1
  • +
  • -

#13 narusasutobi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 08-March 10

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 10 March 2010 - 03:36 AM

Hey I have a problem now... I dont know how to use the srand () function and where to replace it...
In the attachment is the code i have done so far.. it has no errors. but if i run the program... it is different from the original.. please send me your email address and ill send you the ORIGINAL program and the program i have done. the ORIGINAL program doesn't have a .cpp file... although in a zip file i receive along with that is a .cpp file with errors that i am fixing now.. PLEASE HELP ME ON THIS.. THANK YOU VERY MUCH
Was This Post Helpful? 0
  • +
  • -

#14 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 784
  • View blog
  • Posts: 7,613
  • Joined: 05-May 05

Re: ERRORS. UNDECLARED IDENTIFIER.

Posted 11 March 2010 - 11:01 AM

http://www.cplusplus.../cstdlib/srand/

According to the definition of srand, the following is stated:

Two different initializations with the same seed, instructs the pseudo-random generator to generate the same succession of results for the subsequent calls to rand in both cases.

That means that srand() should be called with some number (usually the current milliseconds of the system or something always changing). The following should be true according to this definition:

/* Program entry */
int main()
{
	int a,b,c;
	/* Get three random numbers */
	srand(32);
	a = rand();
	b = rand();
	c = rand();
	/* Should be the same numbers */
	srand(32);
	printf("A: %d, Rand %d\n",a,rand());
	printf("B: %d, Rand %d\n",b,rand());
	printf("C: %d, Rand %d\n",c,rand());
	return 0;
}



When this snippet is run (don't forget to include the necessary headers if you do want to run this) it should demonstrate that these numbers are the same the second time around each time srand is called (and they are).

Therefore, every the time program is initialized, you must call srand. And if you want every run to be different for the program being opened and closed, you have to put a different number in for srand() every time.

This post has been edited by WolfCoder: 11 March 2010 - 11:04 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1