hey guys.. i have problem compiling this code.. i am new to c++ by the way.
this is my code.

// Project.cpp : Defines the entry point for the console application.
// Doodle Program
#include"stdafx.h"
#include<iostream>
#include<conio.h>
#include<random>
using namespace std;
int main(){
	randomize();
	cout<<"Doodler! Press I/J/K/M to move, Q to quit"<<endl;
	char KeyPressed; // key pressed by user
	int x=40; int y=10;
	do{
		// plot a point
		gotoxy(x, y);
		cout<<"*";
		gotoxy(x, y); // Move blinking curser under current spot
		KeyPressed = getch();
		if(KeyPressed == "I" || KeyPressed == "i")
			y--;
		else if(KeyPressed == "T" || KeyPressed == "t")
			y++;
		else if(KeyPressed == "J" || KeyPressed == "j")
			x--;
		else if(KeyPressed == "K" || KeyPressed == "k")
			x++;
		else if(KeyPressed == "Q" || KeyPressed == "q")
			;// do nothing
		else
			cout<<"\a"; // Beep for bad keyword
	} while((KeyPressed != 'Q') && (KeyPressed != 'q'));
	gotoxy(1, 1); // clear and display new title
	clreol();
	cout<<"Random stars! Press any key to stop."<<endl;
	while(!khhit()){
		gotoxy(1+random(60), 2+random(20));
		cout<<"* "; // A start and a blank to draw And Erase
	}
	return(0);
}

so what is wrong on it?? i am using VC++. any help will be highly appreciated!

>> i have problem compiling this code

Post the compilation errors. You may not understand them, but we do. It is hard to know the error, especially since you are using a lot of non-standard functions and headers (gotoxy(), randomize(), random(), clreol(), etc.).

owww. ok, sorry for not posting them..
here is the compilation error:

1>------ Build started: Project: Doodle Project, Configuration: Debug Win32 ------
1>  Doodle Project.cpp
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(9): error C3861: 'randomize': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(15): error C3861: 'gotoxy': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(17): error C3861: 'gotoxy': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(19): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(19): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(19): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(19): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(21): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(21): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(21): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(21): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(23): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(23): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(23): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(23): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(25): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(25): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(25): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(25): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(27): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(27): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(27): error C2446: '==' : no conversion from 'const char *' to 'int'
1>          There is no context in which this conversion is possible
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(27): error C2040: '==' : 'int' differs in levels of indirection from 'const char [2]'
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(32): error C3861: 'gotoxy': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(33): error C3861: 'clreol': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(35): error C3861: 'khhit': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(36): error C3861: 'gotoxy': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(36): error C3861: 'random': identifier not found
1>c:\users\admin\documents\visual studio 2010\projects\doodle project\doodle project\doodle project.cpp(36): error C3861: 'random': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i got this code from the book i am using to learn c++
it is called "A guide to programming in c++" i didnt write it my self.. u know.. i am learning and i wanted to know what can that code do!

Most of the errors are due to the fact that a unique character (as opposed to a string literal) has to be denoted with single quotes ' not double-quotes ".

So, lines 19 to 27 should look more like this version of line 19:

if(KeyPressed == 'I' || KeyPressed == 'i')  //notice the single-quotes 'i', not "i".

The rest of the errors are due to the fact that you use non-standard functions that are probably not present on your implementation.

If you want to learn by looking at example code, try to pick from more reputable sources. This example code is bad, non-standard, and old. It is no example to follow. Try the recommended sources.

thanks very much!
i will try to change it and fix the errors.. thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.