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;
}
}
Comments
Good post

"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 6 Years Ago by Fbody: n/a

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 :)

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.