sleep() and usleep() functions | C Programming Tutorial

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

We, embedded designers, use what is called hibernation mode to minimize power consumption in battery operated devices. Some microcontrollers from NXP (Motorola) can hibernate for over 70 years on one single battery if the right battery is used and the designer knows how to put it in perfect hibernation, this is great for rescu operations or battery operated medical devices that stays inside human body, for life time, to avoid performing intrusive surgical operation on people with certain illnesses. Science can deliver great mercy to humanity once used in the correct way.

fifaham
Автор

helped me alot I thought sleep was in THANK YOU

sobanmalik
Автор

thank you for these videos, they're super helpful. Also, have a question, in the following code I expect it to sleep between each interval but it just sleeps throughout the whole loop. Is this intended behavior? thank you in advance!

#include<stdio.h>
#include<unistd.h>

int main()
{
int start = 5;
printf("starting...\n");
while(start){
printf("%d ", start);
sleep(1);
start--;
}
printf("\n");

return 0;
}

oaly
Автор

Thanks for the tutorial! unfortunately i'm still having trouble with the Sleep function, since everytime i use it it just applies the delay to the entire code.
(im using visual studio code for this)
i pasted my code below this message so you can see it. Thanks in advance!

#include <stdio.h>
#include <unistd.h>


int main(void){


printf("this is a delay test");
sleep(4);
printf("\ni hope it worked");

}

helootheproto
Автор

Che versione del C usa la funzione nanosleep() ?

claudiosilvestri
Автор

can you tell me what should be the output if we use sleep() without arguments.
it varies compiler to compiler, even though this sleep call is not correct but if we use only stdio.h it neither shows error nor it runs properly

char ch = (char)65;
for(int i=0; i<5; i++)
{
for(int j=0; j<5-i; j++)
{
printf("%c ", ch++);
}
sleep();
printf("\n");
}

shubhs.
Автор

sir what does unistd.h stands for(full form).

kamranzaidi
Автор

Using usleep shows "int usleep is deprecated" .... Need help if anyone know the solution 😢

gauravS_
Автор

"cannot open source file "unistd.h"

Jarxay