1

Hey :)

I have written this code, but it seems that theres an error in it, that i can't find. When i try to compile it i get this error: Call to undefined function 'sleep' in function main().

I know it has something to do with that sleep function, because when i remove it, it works.
Someone help me plz :)

#include <iostream.h>
#include <windows.h>

int test;

int main(void)
{
cin >> test;

if(test == 123)
{
	cout << "Venter nu 5 sekunder!";
	sleep(5000);
	cout << "Der er nu gaaet 5 sekunder!";
}
else
{
	cout << "Her er noget galt :P" << endl;
}
}
Votes + Comments
Good post
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Excizted
0

"Call to undefined function..." means that a function's name as written does not exist.

C++ is case sensitive. Have you double-checked your capitalization? Look up the sleep function in your help file for the Windows library.

Edited by Fbody: n/a

0

Hi there :)

I happen to know that the sleep function has a capitalized S.
So you should call Sleep() instead of sleep().

The previous poster already told you what the compilation error means, remember that :)

Also Sleep is defined in the windows libraries, which you did include, so you should be good to go, if you just capitalize your S.

#include <windows.h>

Have fun :)

0

Okay, this actualy made me laugh :D
It worked with making capitalized S never knew that :P
Thx to you guys :D

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.