[問題] function定義後接著struct/int ?
如題,在寫網路模擬的作業,助教給的code
是.c 檔 compile下去一大桶error
但是我有看過程式開頭的註解 確定這個檔不是要學生填空的
而且還警告學生不可以改這個檔的內容...
裡面有很多error是來自於這種函式定義
void InsertEvent(p)
struct event *p;
{
// blah blah blah
} /* END OF InsertEvent */
void stoptimer(AorB)
int AorB; /* A or B is trying to stop timer */
{
//blah blah blah
}
請問 這是什麼語法...我完全沒有印象有看過這種函式定義和{}中間夾著東西
的寫法 .. (constructor除外..)QQ
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.231.96.222
→
12/20 22:59, , 1F
12/20 22:59, 1F
→
12/20 22:59, , 2F
12/20 22:59, 2F
void InsertEvent(p)
struct event *p;
{
// blah blah blah
} /* END OF InsertEvent */
==
void InsertEvent(struct event *p)
{
// blah blah blah
} /* END OF InsertEvent */
void stoptimer(AorB)
int AorB; /* A or B is trying to stop timer */
{
//blah blah blah
}
==
void stoptimer(int AorB)
{
//blah blah blah
}
請問是這個意思嗎@@
※ 編輯: autumned 來自: 61.231.96.222 (12/20 23:03)
推
12/20 23:02, , 3F
12/20 23:02, 3F
→
12/20 23:03, , 4F
12/20 23:03, 4F
→
12/20 23:08, , 5F
12/20 23:08, 5F
→
12/20 23:08, , 6F
12/20 23:08, 6F
裡面還有這種
.... @@
401 C:\Users\user\Desktop\HW3\project3.c aggregate `timeval tp' has
incomplete type and cannot be defined
403 C:\Users\user\Desktop\HW3\project3.c `gettimeofday' undeclared (first use
this function)
void GetTimeNow( double *time_returned )
{
#ifdef WINDOWS
static short first_time = TRUE;
LARGE_INTEGER ticks = {0,0};
LARGE_INTEGER ticks_per_second = {0,0};
static double ticks_per_microsecond;
if ( first_time == TRUE )
{
QueryPerformanceFrequency (&ticks_per_second);
ticks_per_microsecond = (float) ticks_per_second.LowPart / 1E6;
first_time = FALSE;
}
QueryPerformanceCounter (&ticks);
*time_returned = ticks.LowPart/ticks_per_microsecond;
*time_returned += ldexp(ticks.HighPart,32)/ticks_per_microsecond;
*time_returned /= 1E6;
#endif
#ifdef LINUX
struct timeval tp;
gettimeofday (&tp, NULL);
*time_returned = tp.tv_usec;
*time_returned /= 1E6;
*time_returned += tp.tv_sec;
#endif
}
※ 編輯: autumned 來自: 61.231.96.222 (12/20 23:11)
→
12/20 23:12, , 7F
12/20 23:12, 7F
→
12/20 23:15, , 8F
12/20 23:15, 8F
→
12/20 23:18, , 9F
12/20 23:18, 9F
→
12/20 23:19, , 10F
12/20 23:19, 10F
推
12/20 23:42, , 11F
12/20 23:42, 11F
→
12/20 23:44, , 12F
12/20 23:44, 12F
→
12/21 00:02, , 13F
12/21 00:02, 13F
→
12/21 00:29, , 14F
12/21 00:29, 14F
推
12/21 01:16, , 15F
12/21 01:16, 15F
→
12/21 11:54, , 16F
12/21 11:54, 16F
→
12/21 15:17, , 17F
12/21 15:17, 17F
→
12/21 23:58, , 18F
12/21 23:58, 18F
推
12/22 01:33, , 19F
12/22 01:33, 19F
→
12/22 07:44, , 20F
12/22 07:44, 20F
→
12/22 09:25, , 21F
12/22 09:25, 21F
→
12/22 09:25, , 22F
12/22 09:25, 22F
→
12/22 09:26, , 23F
12/22 09:26, 23F
→
12/22 09:26, , 24F
12/22 09:26, 24F
推
12/22 10:21, , 25F
12/22 10:21, 25F
→
12/22 10:22, , 26F
12/22 10:22, 26F
→
12/22 10:57, , 27F
12/22 10:57, 27F