לוגו אתר Fresh          
 
 
  אפשרות תפריט  ראשי     אפשרות תפריט  צ'אט     אפשרות תפריט  מבזקים     אפשרות תפריט  צור קשר     חץ שמאלה ‎print ‎"Hello World!"; if‎ ‎not rules.‎know ‎then rules.‎read(); חץ ימינה  

לך אחורה   לובי הפורומים > מחשבים > תכנות ובניית אתרים
שמור לעצמך קישור לדף זה באתרי שמירת קישורים חברתיים
תגובה
 
כלי אשכול חפש באשכול זה



  #7  
ישן 03-04-2007, 17:15
צלמית המשתמש של scripter
  scripter scripter אינו מחובר  
 
חבר מתאריך: 04.08.02
הודעות: 4,468
בתגובה להודעה מספר 6 שנכתבה על ידי HEN_K שמתחילה ב "האם אתה יכול לתת לי בבקשה קוד (קצר) לדוגמא?"


קוד:
#include <windows.h> #include <stdio.h> #include <stdlib.h> /* #include <strsafe.h> */ #define MY_BUFSIZ 255 #define WHEN_TO_STOP 10 DWORD WINAPI MyThread( LPVOID lpParam ) { int *pInt; HANDLE hStdout; /* TCHAR buf[MY_BUFSIZ]; size_t cchStringSize; DWORD dwChars; */ /* hStdout = GetStdHandle( STD_OUTPUT_HANDLE ); if( hStdout == INVALID_HANDLE_VALUE ) { return 1; } */ pInt = ( int* )lpParam; for( ;; ) { if( *pInt == WHEN_TO_STOP ) { return 0; } ++(*pInt); /* StringCchPrintf( buf, MY_BUFSIZ, TEXT( "test is: %d\t" ), *pInt ); StringCchLength( buf, MY_BUFSIZ, &cchStringSize, NULL ); WriteConsole( hStdout, buf, cchStringSize, &dwChars ); */ printf( "test is: %d\t", *pInt ); Sleep( 1000 ); } return 0; } int main( int argc, char **argv ) { int test = 0; DWORD dwThreadID; HANDLE hThread; hThread = CreateThread( NULL, 0, MyThread, &test, 0, &dwThreadID ); if( hThread == NULL ) { fprintf( stderr, "Failed to create the thread (errid: %d)\n", GetLastError() ); return EXIT_FAILURE; } /* * Your program continues here; */ printf( "Waiting for thread to finish\n" ); WaitForSingleObjectEx( hThread, INFINITE, 0 ); return EXIT_SUCCESS; }

אני מניח שאתה משתמש בווינדוס. (סביר להניח שאם היית משתמש במערכת הפעלה אחרת, לא היית שואל את השאלה )
שמתי הערות בשורות שקשורות ל-strsafe.
_____________________________________
C pogrammers never die. They are just cast into void.


תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
  #14  
ישן 28-05-2007, 10:14
  שימיadmin שימי אינו מחובר  
מנהל פורומי "תכנות ובניית אתרים" ו"חומרה ורשתות"
 
חבר מתאריך: 25.10.01
הודעות: 42,775
בתגובה להודעה מספר 13 שנכתבה על ידי HEN_K שמתחילה ב "אם כבר פתחתם את הדיון מחדש אז יש לי כמה שאלות....."

הפונקציה time (לפחות זו הסטנדרטית שאני מכיר) מחזירה לך את מספר השניות שעברו מ Epoch (שזה 1/1/1970 00:00 לפי שעון גריניץ'). ידוע גם בקרב העולם בתור "unixtime" - הזכרתי את זה מזמן כבר בתחילת האשכול הזה.

time_t הוא סוג המשתנה שהפונקציה הזו מחזירה. כיום, גודל המשתנה הזה קצת מוגבל, וטווח הערכים שלו אמור להסתיים בשנת 2038 - אז תהיה למערכות קצת בעייה, אם לא יפתרו את זה עד אז. אני משער שיפתרו, בסופו של דבר מדובר בהכפלת המשתנה, מה שייצור משתמש שריד לעוד אלפי שנים...

הנה ההגדרה הרשמית של הפונ':
קוד:
TIME(2) Linux Programmer's Manual TIME(2) NAME time - get time in seconds SYNOPSIS #include <time.h> time_t time(time_t *t); DESCRIPTION time() returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in sec- onds. If t is non-NULL, the return value is also stored in the memory pointed to by t. RETURN VALUE On success, the value of time in seconds since the Epoch is returned. On error, ((time_t)-1) is returned, and errno is set appropriately. ERRORS EFAULT t points outside your accessible address space. NOTES POSIX.1 defines seconds since the Epoch as a value to be interpreted as the number of sec- onds between a specified time and the Epoch, according to a formula for conversion from UTC equivalent to conversion on the naive basis that leap seconds are ignored and all years divisible by 4 are leap years. This value is not the same as the actual number of seconds between the time and the Epoch, because of leap seconds and because clocks are not required to be synchronised to a standard reference. The intention is that the interpre- tation of seconds since the Epoch values be consistent; see POSIX.1 Annex B 2.2.2 for fur- ther rationale. CONFORMING TO SVr4, 4.3BSD, C89, C99, POSIX.1-2001. POSIX does not specify any error conditions. SEE ALSO date(1), gettimeofday(2), ctime(3), ftime(3), time(7) Linux 2.0.30 1997-09-09 TIME(2)
_____________________________________
תמונה שהועלתה על ידי גולש באתר ולכן אין אנו יכולים לדעת מה היא מכילה
נמאס לכם לזכור סיסמאות? לחצו כאן!

תגובה ללא ציטוט תגובה עם ציטוט חזרה לפורום
תגובה

כלי אשכול חפש באשכול זה
חפש באשכול זה:

חיפוש מתקדם
מצבי תצוגה דרג אשכול זה
דרג אשכול זה:

מזער את תיבת המידע אפשרויות משלוח הודעות
אתה לא יכול לפתוח אשכולות חדשים
אתה לא יכול להגיב לאשכולות
אתה לא יכול לצרף קבצים
אתה לא יכול לערוך את ההודעות שלך

קוד vB פעיל
קוד [IMG] פעיל
קוד HTML כבוי
מעבר לפורום



כל הזמנים המוצגים בדף זה הם לפי איזור זמן GMT +2. השעה כעת היא 06:01

הדף נוצר ב 0.05 שניות עם 10 שאילתות

הפורום מבוסס על vBulletin, גירסא 3.0.6
כל הזכויות לתוכנת הפורומים שמורות © 2024 - 2000 לחברת Jelsoft Enterprises.
כל הזכויות שמורות ל Fresh.co.il ©

צור קשר | תקנון האתר