i am not able to use sleep function in C++ by windows.h
so i need a substitute function which takes milliseconds as arguments!!!
i am not able to use sleep function in C++ by windows.h
so i need a substitute function which takes milliseconds as arguments!!!
> i am not able to use sleep function in C++ by windows.h
Why not?
It takes milliseconds as a parameter
Sleep function (Windows)
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
only one error and these warnings!!!
the tournament.o:the tournament.cpp.text+0x5b): undefined reference to `sleep(int)'
the tournament.o:the tournament.cpp.text+0xfd): undefined reference to `sleep(int)'
the tournament.o:the tournament.cpp.text+0x17f): undefined reference to `sleep(int)'
the tournament.o:the tournament.cpp.text+0x258): undefined reference to `sleep(int)'
the tournament.o:the tournament.cpp.text+0x2a8): undefined reference to `sleep(int)'\
(here every smiley face shows ": (" )
error
collect2.exe: error: ld returned 1 exit status
now i'll reply after 8-20 hrs later its 1 hr left to midnight here and i m feeling ZZzzZZzz.....
You may want to study the link Salem provided, and notice the difference in spelling and remember C/C++ is case sensitive.
Jim
ummm..... no nothing is working i included the windows.h file + looked for all spell mistake and after that still this function is undefined!!!(some of you might think that i am just lying but i am serious)
Then post your code that exhibits the problem so maybe we can see what you're doing wrong.
How did you spell the function sleep() or Sleep()?
And how did you spell windows.h?
Jim
there are 12 files including a header file but i'll show the one with int main()
Code:#include"Player.h" #include<iostream> #include<conio.h> #include<time.h> #include<stdlib.h> #include<string.h> #include<windows.h> using namespace std; void clear(); void noem(); void story(int); void quit(int&); Player p; Player::enemy e; void ab() { system("cls"); cout<<"you had purchased this item before\n"; getch(); }//end of ab() void noem() { system("cls"); cout<<"you have not enough money to buy this item...\n"; sleep(2000); system("cls"); }//end of noem() void Player :: bou() { system("cls"); cout<<"you bought this weapon named : "<<p.wpn; cout<<"and having damage : "<<p.dam[0]<<"-"<<p.dam[1]; sleep(2500); system("cls"); }//end of bou() void Player :: boa() { system("cls"); cout<<"you bought this armour named : "<<p.armname; cout<<"and having strength : "<<p.arm; sleep(2500); system("cls"); }//end of boa() void quit(int &j) { system("cls"); char a; cout<<"are you sure want to quit?(y/n)"; a=getch(); switch(a) { case 'y': case 'Y':{ system("cls"); cout<<"thanks for playing this game "; for(int i=0;i<10;i++) { cout<<(char)1<<" "<<(char)2; sleep(2800); cout<<"\b\b\b"<<(char)2<<" "<<(char)1; sleep(2800); cout<<"\b\b\b"; } j++; } case 'n': case 'N':break; default :cout<<"\nchoose one of the two (y/n)\n"; quit(j); }//end of switch(a) inside function quit() cout<<"\n"; system("pause"); }//end of function quit() int main() { int reset=0; for(int i=0;i!=1;) { system("cls"); char a; cout<<"welcome to \'the tournament\'\n"; cout<<"press...\n (1) to start\n (2) for tutorial\n (3) for options\n (4) to quit"; a=getch(); cout<<"\n"; switch(a) { case '1':p.start(reset,p,e);break; case '2':/**/break; case '3':p.options(reset,p);break; case '4':quit(i);break; } }//end of for return 0; }//end of main()
Look closely at the following snippet:
Is that how Sleep() is spelled in the Microsoft documentation you have been provided. C/C++ is case sensitive.Code:void noem() { system("cls"); cout<<"you have not enough money to buy this item...\n"; sleep(2000);
Jim
oh kayy then tell me is it small 's' or capital one???
oh kayyyy got it its capital one i'll take care now actually i thought that its rare that we declare a function with capital letters!!! thanks
jim
thanks Elysia i'll take care for that too!!