Hello, I've been looking arround the internet, and I found the command wait(15); to wait for 15 secons.
I used the header #include <time.h> and I got an error.
Can someone please help me and tell me what I've been doing wrong?
No you haven't. Windows uses Sleep() not sleep() (capital S). Also, *nix sleep() parameter is in seconds -- MS-Windows Sleep() parameter is milliseconds.
Ok. It was a long time ago (10+ years), so I probably put an #ifdef in a header to convert sleep(n) to Sleep(n) when it was compiling on a Windows system. This was code that ran on Unix systems as well as Windows, and there was a lot of that sort of cruft to get common code to build on Windows. When it comes to programming standards, there is the POSIX world, and then there is Microsoft's world - ne'er the twain shall meet!
Note that the wait(int) function is user-defined in this example rather than supplied by time.h.
Not necessarily a good approach. This will suck up a huge amount of cpu, a tight loop making a system call like this. In effect, the sleep(n) or Sleep(n) function does a kernel call to set an interval timer and wakes up when the time expires. Because this is handled in the kernel idle loop, without recourse to a user loop, it effectively takes no CPU time at all.
Not necessarily a good approach. This will suck up a huge amount of cpu, a tight loop making a system call like this.
Agreed. I don't think anyone was actually recommending that solution. I think it was on cplusplus.com's site since it was a good example of clock(), not a good example of how to pause. Overall point is that pausing appears to be OS-specific.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...