-6

In a book, I saw a piece of code.

command line aurguments

but when I ran this code it said: C:\Users\dipankar\Desktop\cla.cpp [Error] 'delay' was not declared in this scope

They used it without proper documentation. They only said that "delay() is used to delay the execution of the next line by few milliseconds"!!. please help.

user3382203
  • 169
  • 1
  • 6
  • 25
dipankar pal
  • 63
  • 1
  • 11

3 Answers3

7

The book you are reading is crap. Avoid the book and tell others to do the same.

The book probably comes from the 1980s or early 1990s. There is a function delay in Turbo Pascal that takes milliseconds. Maybe that's the one the author means.

Roland Illig
  • 40,703
  • 10
  • 88
  • 121
3

It's a millisecond delay function. Where it's defined depends a lot on what platform/toolchain you're compiling against. Often it would be found in <time.h>

ctacke
  • 66,480
  • 18
  • 94
  • 155
  • i have added #include but same result !! – dipankar pal Apr 30 '17 at 18:38
  • Again, it greatly depends on your platform and toolchain. We have no idea what you're targeting or what would be "standardly" available. We can't even really suggest a modern equivalent without that info. – ctacke Apr 30 '17 at 18:58
0

I am not aware of any sleep function as part of the C standard. However, you would use nanosleep (https://linux.die.net/man/2/nanosleep) for this purpose in Linux.

eega
  • 479
  • 8
  • 20