Notice: file_put_contents(): Write of 1419 bytes failed with errno=28 No space left on device in /var/www/tgoop/post.php on line 50

Warning: file_put_contents(): Only 16384 of 17803 bytes written, possibly out of free disk space in /var/www/tgoop/post.php on line 50
Learning ©➕➕@Learncpp P.1249
LEARNCPP Telegram 1249
#ctime #time.h #difftime
🔵زمان (time)

🔹تابع difftime

double difftime(time_t end,time_t beginning);

این تابع اختلاف دو زمان را که به صورت زمان غیر استاندارد(یا همان time_t است)را محاسبه می کند.
البته درست این است که این تابع فقط نوع time_t که همان ثانیه ها هست را محاسبه می کند ولی می توانیم کاری کنیم که حتی اختلاف ماه و سال و روز را هم محاسبه کنیم.


🔹پارامتر ها :

🔻مفهوم end :
این همان زمان اولیه است که می خواهیم اختلافش تا زمان ثانویه را محاسبه کنیم.

🔻مفهوم beginning :
این همان زمان ثانویه است.

🔹مقادیر بازگشتی :
یک مقدار از نوع double که همان اختلاف زمان به ثانیه است

#include <iostream>
#include <ctime>
using namespace std;

int main( )
{
time_t tim1,tim2;
double s;
time(&tim1);
for(int i=0;i<=9999;i++)
{
//دستورات
}
time(&tim2);
s=difftime(tim1,tim2);
cout<<s<<endl;
return 0;
}

مثال بالا زمان تلف شده توسط یک تکه کد را محاسبه می کند.

#include <iostream>
#include <time.h>
/* time_t, struct tm, difftime, time, mktime */
using namespace std;

int main ( )
{
time_t now;
struct tm newyear;
double seconds;

time(&now);
/*get current time;same as:now=time(NULL) */

newyear=*localtime(&now);

newyear.tm_hour=0;
newyear.tm_min=0;
newyear.tm_sec=0;
newyear.tm_mon=0;
newyear.tm_mday=1;

seconds=difftime(now,mktime(&newyear));

cout<<seconds since new year in the current timezone.\n"<<seconds;

return 0;
}


Output:
3777291 seconds since new year in the current timezone.

برنامه بالا یک مثال برای پیدا کردن اختلاف روز است.

🔰ترجمه شده از سایت
www.cplusplus.com

@Learncpp



tgoop.com/Learncpp/1249
Create:
Last Update:

#ctime #time.h #difftime
🔵زمان (time)

🔹تابع difftime

double difftime(time_t end,time_t beginning);

این تابع اختلاف دو زمان را که به صورت زمان غیر استاندارد(یا همان time_t است)را محاسبه می کند.
البته درست این است که این تابع فقط نوع time_t که همان ثانیه ها هست را محاسبه می کند ولی می توانیم کاری کنیم که حتی اختلاف ماه و سال و روز را هم محاسبه کنیم.


🔹پارامتر ها :

🔻مفهوم end :
این همان زمان اولیه است که می خواهیم اختلافش تا زمان ثانویه را محاسبه کنیم.

🔻مفهوم beginning :
این همان زمان ثانویه است.

🔹مقادیر بازگشتی :
یک مقدار از نوع double که همان اختلاف زمان به ثانیه است

#include <iostream>
#include <ctime>
using namespace std;

int main( )
{
time_t tim1,tim2;
double s;
time(&tim1);
for(int i=0;i<=9999;i++)
{
//دستورات
}
time(&tim2);
s=difftime(tim1,tim2);
cout<<s<<endl;
return 0;
}

مثال بالا زمان تلف شده توسط یک تکه کد را محاسبه می کند.

#include <iostream>
#include <time.h>
/* time_t, struct tm, difftime, time, mktime */
using namespace std;

int main ( )
{
time_t now;
struct tm newyear;
double seconds;

time(&now);
/*get current time;same as:now=time(NULL) */

newyear=*localtime(&now);

newyear.tm_hour=0;
newyear.tm_min=0;
newyear.tm_sec=0;
newyear.tm_mon=0;
newyear.tm_mday=1;

seconds=difftime(now,mktime(&newyear));

cout<<seconds since new year in the current timezone.\n"<<seconds;

return 0;
}


Output:
3777291 seconds since new year in the current timezone.

برنامه بالا یک مثال برای پیدا کردن اختلاف روز است.

🔰ترجمه شده از سایت
www.cplusplus.com

@Learncpp

BY Learning ©➕➕


Share with your friend now:
tgoop.com/Learncpp/1249

View MORE
Open in Telegram


Telegram News

Date: |

Telegram has announced a number of measures aiming to tackle the spread of disinformation through its platform in Brazil. These features are part of an agreement between the platform and the country's authorities ahead of the elections in October. Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. A Hong Kong protester with a petrol bomb. File photo: Dylan Hollingsworth/HKFP. best-secure-messaging-apps-shutterstock-1892950018.jpg Telegram Channels requirements & features
from us


Telegram Learning ©➕➕
FROM American