2014-11-23 70 views
0

我已經重寫了一個函數,我需要一個項目來構建媒體數據庫,其中包含媒體本身的信息。 在下面這段代碼中,我試圖從標題長度爲HH:MM:SS的用戶獲取一個字符串。 然後,我必須使用第一個isdigit字符串的指針分割字符數小時,第一個isdigit字符後第一個「:」分鐘和第一個isdigit字符後最後一個「:」檢查字符串是否與我想要的用戶進入。 爲了檢查子字符串是否合法,我使用atoi轉換爲int並嘗試寫入結構,但指針正在烘烤我。 任何幫助表示讚賞。編譯錯誤,成員不是工會的成員|使用指針/結構體

赫雷什代碼本身(用於引擎收錄更好的可讀性)datetime.c with functions to examine string and put pointers on first digit of the input, first digit after first: and first digit after last:

我評論其中編譯錯誤發生(在引擎收錄L.103 105 107)

爲了獲得更好的見解這裏的結構使用im:

datastructure.h everything but char * zeit is required as written

事先我真的感覺THX愚蠢最近試圖迫使它通過試錯來編譯,我不認爲我越來越接近目的地在所有...

編輯:當我嘗試編譯:

||=== Build: Debug in Iue2 (compiler: GNU GCC Compiler) ===| 
C:\Users[...]\datetime.c||In function 'convertStringToTime':| 
C:\Users[...]\datetime.c|104|error: request for member 'hour' in something not a structure or union| 
C:\Users[...]\datetime.c|106|error: request for member 'minute' in something not a structure or union| 
C:\Users[...]1\datetime.c|108|error: request for member 'second' in something not a structure or union| 
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===| 
+0

使用['strtol'](http://en.cppreference.com/w/c/string/byte/strtol),您可以同時進行驗證和轉換。 – 2014-11-23 20:32:00

+0

至於你的問題,*你得到了什麼*錯誤?請*編輯您的問題*以包含完整和未經編輯的錯誤日誌。 – 2014-11-23 20:36:03

+0

已更新。對不起,我認爲將其添加到行,並指出它是好的。 – 2014-11-23 20:40:13

回答

0

線74被破壞:不是無效convertStringToTime(字符* strTime,TTIME *時代週報)它必須是無效convertStringToTime(焦* strTime,TTime * lp)。其他任何東西似乎都很好。 將嘗試現在完成內存分配並查看strtol()作爲替代解決方案。