好的,這就是我想要做的,我的總體目標是創建一個狙擊機器人來狙擊(使用的術語是)“OG 用戶名”我目前在頭檔案中使用結構,我這樣做的原因是減少代碼重復,使程式運行更高效。我的總體目標是從網頁中提取時間戳并計算運行任務的確切時間(以毫秒為單位)。
在頭檔案中它有這個:
struct TimeTilNameDrop
{
int days; //Integer for days
int hours; //Integer for hours
int minutes; //Integer for minutes
int seconds; //Integer for seconds
int miliseconds; //Integer for miliseconds
};
我試圖在幾天、幾小時、幾分鐘、幾秒內獲取用戶的輸入,但我不能讓它計算毫秒,我很欣賞這不準確,因為程式運行任務的時間需要幾毫秒我需要考慮到這一點。
#pragma warning(disable : 4996)
#include <iostream>
#include <ctime>
#include <time.h>
#include <NameDropData.h> //The headerfile containing the struct
using namespace std;
//Linker Decleration.
struct TimeTilNameDrop;
void Test(TimeTilNameDrop);
int TurboSnipe(Test)
{
cout << "Please enter the days til name drop";
cin >> days;
cout << "Please enter the hours til name drop";
cin >> hours;
cout << "Please enter the minutes til name drop";
cin >> minutes;
cout << "Please enter the seconds til name drop";
cin >> seconds;
}
我已經嘗試查看其他教程,其中結構位于頭檔案中,我知道它可能會在其本地類中作業。但是,我喜歡效率的概念。任何幫助,將不勝感激。
PS我是菜鳥,這是我的第一個專案。我知道它可能不起作用,或者我可能沒有能力,但我認為這將是一個很好的專案。
哦,如果有人對任何好的 C 視頻課程有任何建議,歡迎提出建議,我目前一直在做“The Cherno's” C 系列,我剛剛了解了指標的作業原理。
歡迎提出建議:)
uj5u.com熱心網友回復:
我假設您正在嘗試根據您的描述將資訊存盤到結構中。我注意到您當前所做的主要問題是您從未創建結構的實體。您需要創建結構的實體以在其中存盤資訊。以下是如何做到這一點的示例:
//header file where stuct is
#include "stackOverflow.h"
//linker declaration for struct
struct TimeTilNameDrop;
using namespace std;
int main() {
//create an instance of the stuct named timeStruct
TimeTilNameDrop timeStruct;
cout << "Please enter the days til name drop"<<endl;
cin >> timeStruct.days;
cout << "Please enter the hours til name drop"<<endl;
cin >> timeStruct.hours;
cout << "Please enter the minutes til name drop"<<endl;
cin >> timeStruct.minutes;
cout << "Please enter the seconds til name drop"<<endl;
cin >> timeStruct.seconds;
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/420779.html
標籤:
