   how do you use a delay  in c++
  How do I use a delayI tryed this and I get that it is undeclared delay(DELAY);I am using dev-cpp 
  ... what do you mean "delay"?  Have you tried the Sleep() function?   ;void display_logo(){cout<<"   EEEEEEEE  L    IIIIIII  ZZZZZZZ AAA"<<endl;delay(DELAY);cout<<"   E    L  IZ A   A    "<<endl;delay(DELAY);cout<<"   E    L  I    Z AA   "<<endl;delay(DELAY);cout<<"   EEEEEL  I   Z  AA   "<<endl;delay(DELAY);cout<<"   E    L  I  Z   AAAAAAA   "<<endl;delay(DELAY);cout<<"   E    L  I Z    AA   "<<endl;delay(DELAY);cout<<"   EEEEEEEE  LLLLLLLL  IIIIIII  ZZZZZZAA   "<<endl;}delay(RanNum(DELAY)); [edited by - kingpinzs on February 9, 2004 10:15:27 PM];  wtf is that ?   "A soldier is a part of the 1% of the population that keeps the other 99% free"  - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA ;  there is no fuction Delay or RandNum! Wtf book you been reading.C++ DOESNT HAVE JUST ANY NAMED FUNTION!    ;  O_Olay off teh drugz d00d!~! ;  I got it from HEREhttp://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369I downloaded the source and I cant get it to run ;  It looks like ranNum might just be a user defined function, but its nowhere in the code. same thing with delay and DELAY might be a preprocessor macro that the author should have made..but again its not there.  ;quote:Original post by kingpinzs  I got it from HEREhttp://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369I downloaded the source and I cant get it to run   I REVISED THE CODE TO SOMETHING THAT WORKS!REPLACE THE WHOLE SOURCE FILE THITH THIS! /* Including Files */# include<iostream># include<conio.c># include<string># include<time.h># include<math.h># include<stdlib.h># include<windows.h># include<stdio.h># include<fstream>/* Defining Costants*/// Max. length in characters of any automated reply ( Keyword only)# define MAX_RESP_LEN 65// Max. number of responses for any keyword# define MAX_RESP_NO 20// Max. number of keywords# define MAX_KEY 13// Max. number of Transpositions# define TRANSPOSE 12// Max. Size Of User Input# define MAX_USER_INPUT 100// Max. Length of Keyword# define MAX_KWD_LEN 20// Delay involved in typing (in ms)# define DELAY 20/* Defining Global Variables */using namespace std;char user[30];// for word transpositionschar wordin[TRANSPOSE][MAX_RESP_LEN];char wordout[TRANSPOSE][MAX_RESP_LEN];int RanNum(int max);void initialize_global();class progstr{public:char userip[MAX_USER_INPUT];char keyword[30];int keyfound;int keyno;int nullip;// constructorprogstr(){keyno=-1;nullip=0;}}ip;class resp{int tot_resp;int last_resp;char replys[MAX_RESP_NO][MAX_RESP_LEN];char word[MAX_KWD_LEN];public:// constructorresp(){tot_resp=0;last_resp=-1;}int getcount(){return last_resp;}void addword(char str[MAX_KWD_LEN]){strcpy(word,str);}char * getword(){return word;}void addresp(char  str[MAX_RESP_LEN]){strcpy(replys[++last_resp],str);}void display_resp(int num);void quit_display_resp(int num);};void display_logo(){cout<<"   EEEEEEEE  L    IIIIIII  ZZZZZZZ AAA"<<endl;Sleep(DELAY);cout<<"   E    L  IZ A   A    "<<endl;Sleep(DELAY);cout<<"   E    L  I    Z AA   "<<endl;Sleep(DELAY);cout<<"   EEEEEL  I   Z  AA   "<<endl;Sleep(DELAY);cout<<"   E    L  I  Z   AAAAAAA   "<<endl;Sleep(DELAY);cout<<"   E    L  I Z    AA   "<<endl;Sleep(DELAY);cout<<"   EEEEEEEE  LLLLLLLL  IIIIIII  ZZZZZZAA   "<<endl;}void display_line(){int width=80;int i=0;int x=wherex();int y=wherey()+1;x=40;for(int k=0;k<40;k++){Sleep(DELAY);gotoxy(x+k,y);cout<<(char)240;gotoxy(x-k,y);Sleep(DELAY);cout<<(char)240;}cout<<"\n";}void resp :: display_resp(int num){cout<<"ELIZA > ";for(int i=0;i<strlen(replys[num]);i++){// for deliberate typing errorsif(RanNum(6)==0){  char c=RanNum(100);if(c==''\n'' || c==''\b'' || c==13)cout<<"w";elsecout<<c;Sleep(RanNum(DELAY));cout<<"\b";}if(replys[num][i]==''*''){char * s1=ip.userip+strlen(ip.keyword);short int flag=0;for(int m=0;m<TRANSPOSE;m++){char * s2=wordin[m];char *ptr=NULL;ptr=strstr(s1,s2);if(ptr!=NULL){// transposition word found in the// user inputflag=1;// printing text before wordin[m]int times=ptr-s1;for(int i=0;i<times;i++){Sleep(DELAY);cout<<ip.userip[strlen(ip.keyword)+i];}// printing the wordoutcout<<wordout[m];// printing the left overschar c;c=*(ptr+strlen(wordin[m]));int t=0;while(c!=''\0''){cout<<*(ptr+strlen(wordin[m])+t);t++;c=*(ptr+strlen(wordin[m])+t);}}} // end of for// if flag is still zero , this means no transpose.if(0==flag){char c;c=*(s1+strlen(ip.keyword));int t=0;while(c!=''\0''){cout<<*(s1+t);t++;c=*(s1+t);}} // end of ifbreak;}else{cout<<replys[num][i];Sleep(RanNum(DELAY));}} // end of forcout<<"\n"<<user<<" > ";}void resp :: quit_display_resp(int num){cout<<"ELIZA > ";for(int i=0;i<strlen(replys[num]);i++){// for deliberate typing errorsif(RanNum(6)==0){  char c=RanNum(100);if(c==''\n'' || c==''\b'' || c==13)cout<<"w";elsecout<<c;Sleep(RanNum(DELAY));cout<<"\b";}cout<<replys[num][i];Sleep(RanNum(DELAY));} // end of for}resp keys[MAX_KEY];int RanNum(int max){//randomize();return rand() % max;}void find_keyword(){int len=0;int lenkey=0;int key_no=0;char teststr[50];while((ip.keyfound==0) &&(key_no!=MAX_KEY)){// getting the length of the keywordlenkey=strlen(keys[key_no].getword());char *ptr=NULL;ptr=strstr(ip.userip,keys[key_no].getword());if (ptr!=NULL){// keyword found !ip.keyfound=1;ip.keyno=key_no;strcpy(ip.keyword,keys[key_no].getword());break;}/*//////////////////////////////////////////for(int i=0;i<lenkey;i++){teststr=ip.userip;<br>}<br>teststr=''\0'';<br>if (strcmp(teststr,keys[key_no].getword())==0)<br>{<br>ip.keyfound=1;<br>ip.keyno=key_no;<br>strcpy(ip.keyword,keys[key_no].getword());<br>}<br>//////////////////////////////////////////*/</font><br></font><br>key_no++;<br>}<br>}<br><br><font color=blue>void</font> read_from_file()<br>{<br>ifstream fin;<br><font color=blue>int</font> index=-1;<br>fin.open(<font color=darkred>"eliza.dat"</font>);<br><font color=blue>char</font> line[<font color=purple>MAX_RESP_LEN</font>];<br><font color=blue>while</font>(fin)<br>{<br>fin.getline(line,MAX_RESP_LEN);<br><font color=blue>char</font> *ptr=NULL;<br>ptr=strstr(<font color=darkred>"@KWD@"</font>,line);<br><font color=blue>if</font>(strlen(line)&lt;1)<br>{<br><font color=blue>break</font>;<br>}<br><font color=blue>else</font> <font color=blue>if</font>(ptr!=NULL)<br>{<br><font color=gray>// the next line is a keyword<br></font><br>fin.getline(line,MAX_RESP_LEN);<br>keys[<font color=purple>++index</font>].addword(line);<br>}<br><font color=blue>else</font><br>{<br><font color=gray>// it is a response<br></font><br>keys[<font color=purple>index</font>].addresp(line);<br>}<br><br>} <font color=gray>// end of while<br></font><br>} <font color=gray>// end of function<br></font><br><br><font color=blue>int</font> main()<br>{<br>clrscr();<br><br>display_line();<br>display_logo();<br>display_line();<br><font color=gray>// for initializing the global variables<br></font><br>initialize_global();<br><br><font color=gray>// for no response by the user.<br></font><br>resp null_resp;<br>null_resp.addresp(<font color=darkred>"HUH ?"</font>);<br>null_resp.addresp(<font color=darkred>"WHAT ?"</font>);<br>null_resp.addresp(<font color=darkred>"COME AGAIN ?"</font>);<br>null_resp.addresp(<font color=darkred>"HOW I AM SUPPOSED TO TALK IF YOU DON''T SAY ANYTHING ?"</font>);<br><br><font color=gray>// upon  logging in<br></font><br>resp signon;<br>signon.addresp(<font color=darkred>"HI, I''M ELIZA. WHAT DO YOU WANT TO TALK ABOUT ?"</font>);<br>signon.addresp(<font color=darkred>"SO HOW ARE YOU DOING TODAY ?"</font>);<br>signon.addresp(<font color=darkred>"HELLO, WHAT''S UP TODAY ?"</font>);<br><br><font color=gray>// when no key found<br></font><br>resp no_key;<br>no_key.addresp(<font color=darkred>"PLEASE GO ON…"</font>);<br>no_key.addresp(<font color=darkred>"WHAT DOES THAT SUGGEST TO YOU ?"</font>);<br>no_key.addresp(<font color=darkred>"I SEE"</font>);<br>no_key.addresp(<font color=darkred>"I''M NOT SURE I KNOW WHAT YOU ARE TALKING ABOUT "</font>);<br>no_key.addresp(<font color=darkred>"WHAT''S THAT SUPPOSED TO MEAN ?"</font>);<br>no_key.addresp(<font color=darkred>"CAN YOU CLARIFY THAT A BIT ?"</font>);<br>no_key.addresp(<font color=darkred>"THAT''S INTERESTING…"</font>);<br>no_key.addresp(<font color=darkred>"AND ????"</font>);<br><br>resp bye;<br>bye.addresp(<font color=darkred>"GOOD BYE, HAVE A NICE DAY…"</font>);<br>bye.addresp(<font color=darkred>"BYE, HOPE TO SEE YOU SOON…"</font>);<br>bye.addresp(<font color=darkred>"BYE AND KEEP IN TOUCH…"</font>);<br><font color=gray>// reading data from dictionary<br></font><br>read_from_file();<br><br><font color=gray>// STARTING CONVERSATION WITH THE USER<br></font><br><font color=gray>// welcoming the user<br></font><br><br>cout&lt;&lt;<font color=darkred>"ELIZA &gt; (PLEASE TYPE IN ALL CAPS) WHAT''S YOUR NAME DEAR ?\n"</font>;<br>cin&gt;&gt;user;<br>signon.display_resp(RanNum(signon.getcount()));<br>fflush(stdin);<br>gets(ip.userip);<br>strcpy(ip.userip,strupr(ip.userip));<br><font color=blue>while</font>(strcmp(ip.userip,<font color=darkred>"BYE"</font>)!=0)<br>{<br>find_keyword();<br><font color=blue>if</font>(strlen(ip.userip)&lt;1)<br>{<br>null_resp.display_resp(RanNum(null_resp.getcount()));<br>}<br><font color=blue>else</font> <font color=blue>if</font>(ip.keyfound==1)<br>{<br>keys[<font color=purple>ip.keyno</font>].display_resp(RanNum(keys[<font color=purple>ip.keyno</font>].getcount()));<br>}<br><font color=blue>else</font><br>{<br>no_key.display_resp(RanNum(no_key.getcount()));<br>}<br><font color=gray>// again returning to normal values of the data items<br></font><br>strcpy(ip.userip,<font color=darkred>" "</font>);<br>ip.keyno=-1;<br>ip.keyfound=0;<br>fflush(stdin);<br>gets(ip.userip);<br>strcpy(ip.userip,strupr(ip.userip));<br>} <font color=gray>// end of while<br></font><br>bye.quit_display_resp(RanNum(null_resp.getcount()));<br>cout&lt;&lt;endl;<br>display_line();<br>cout&lt;&lt;<font color=darkred>"\t\t\tIMPORTANT\n\nPlease note that the current functionality and \<br>features of this program are very limited and they are just for \<br>accompanying the article that I posted on Planet Source Code. If you want \<br>to make this program more intelligent, make entries in Eliza.Dat file. \<br>\n You can also increase the string manipulation power of the program, \<br>like considering multiple lines from the user, etc. I had written this code in 1 1/2 hr. \<br>just to make it more easier for the readers of my article about what is \<br>happening.\n\n HOW SMART YOU MAKE YOUR ELIZA DEPENDS ON HOW FAR YOU EXTEND \<br>THIS PROGRAM. THERE IS PRACTICALLY NO LIMIT ! \n\n\n\<br>THIS CODE IS THE MINIMAL WORKING SKELETON !!\n\n"</font>;<br>display_line();<br>getch();<br>}<br><br><br><font color=blue>void</font> initialize_global()<br>{<br>strcpy(wordin[<font color=purple>0</font>],<font color=darkred><font color=darkred>"ARE"</font></font>);<br>strcpy(wordout[<font color=purple>0</font>],<font color=darkred><font color=darkred>"AM"</font></font>);<br><br>strcpy(wordin[<font color=purple>1</font>],<font color=darkred><font color=darkred>"AM"</font></font>);<br>strcpy(wordout[<font color=purple>1</font>],<font color=darkred><font color=darkred>"ARE"</font></font>);<br><br>strcpy(wordin[<font color=purple>2</font>],<font color=darkred><font color=darkred>"WERE"</font></font>);<br>strcpy(wordout[<font color=purple>2</font>],<font color=darkred><font color=darkred>"WAS"</font></font>);<br><br>strcpy(wordin[<font color=purple>3</font>],<font color=darkred><font color=darkred>"WAS"</font></font>);<br>strcpy(wordout[<font color=purple>3</font>],<font color=darkred><font color=darkred>"WERE"</font></font>);<br><br>strcpy(wordin[<font color=purple>4</font>],<font color=darkred><font color=darkred><font color=darkred><font color=darkred>"YOU"</font></font></font></font>);<br>strcpy(wordout[<font color=purple>4</font>],<font color=darkred><font color=darkred><font color=darkred>"ME"</font></font></font>);<br><br>strcpy(wordin[<font color=purple>5</font>],<font color=darkred>" I "</font>);<br>strcpy(wordout[<font color=purple>5</font>],<font color=darkred><font color=darkred><font color=darkred><font color=darkred>"YOU"</font></font></font></font>);<br><br>strcpy(wordin[<font color=purple>6</font>],<font color=darkred><font color=darkred>"YOUR"</font></font>);<br>strcpy(wordout[<font color=purple>6</font>],<font color=darkred><font color=darkred>"MY"</font></font>);<br><br>strcpy(wordin[<font color=purple>7</font>],<font color=darkred><font color=darkred>"MY"</font></font>);<br>strcpy(wordout[<font color=purple>7</font>],<font color=darkred><font color=darkred>"YOUR"</font></font>);<br><br>strcpy(wordin[<font color=purple>8</font>],<font color=darkred><font color=darkred>"I''VE"</font></font>);<br>strcpy(wordout[<font color=purple>8</font>],<font color=darkred><font color=darkred>"YOU''VE"</font></font>);<br><br>strcpy(wordin[<font color=purple>9</font>],<font color=darkred><font color=darkred>"YOU''VE"</font></font>);<br>strcpy(wordout[<font color=purple>9</font>],<font color=darkred><font color=darkred>"I''VE"</font></font>);<br><br>strcpy(wordin[<font color=purple>10</font>],<font color=darkred><font color=darkred>"I''M"</font></font>);<br>strcpy(wordout[<font color=purple>10</font>],<font color=darkred><font color=darkred>"YOU''RE"</font></font>);<br><br>strcpy(wordin[<font color=purple>11</font>],<font color=darkred><font color=darkred>"YOU''RE"</font></font>);<br>strcpy(wordout[<font color=purple>11</font>],<font color=darkred><font color=darkred>"I''M"</font></font>);<br><br>strcpy(wordin[<font color=purple>12</font>],<font color=darkred><font color=darkred><font color=darkred>"ME"</font></font></font>);<br>strcpy(wordout[<font color=purple>12</font>],<font color=darkred><font color=darkred><font color=darkred><font color=darkred>"YOU"</font></font></font></font>);<br><br>strcpy(wordin[<font color=purple>13</font>],<font color=darkred><font color=darkred><font color=darkred><font color=darkred>"YOU"</font></font></font></font>);<br>strcpy(wordout[<font color=purple>13</font>],<font color=darkred><font color=darkred><font color=darkred>"ME"</font></font></font>);<br><br>}<br></pre><!–ENDSCRIPT–>    <br><br><img src="http://infinateworlds.5u.com/mml.jpg">   <br>   ;quote:Original post by kingpinzs  I got it from HEREhttp://www.pscode.com/vb/scripts/ShowCode.asp?lngWId=3&txtCodeId=5369I downloaded the source and I cant get it to run   The author states he''s using Turbo C IDE 3.0.  Don''t know much about it personally, but it sounds like those functions are Turbo C specific.