嗨,我希望能夠對我的數據輸入到我的結構'數據包'上的'數據'條目進行一些驗證。C編程 - 檢查字符,並停止數組超過50個字符長
基本上它只能有50個字符長,只有數字輸入。
struct packet{ // declare structure for packet creation
int source;
int destination;
int type;
int port;
char data[50];
};
struct packet list[50]; //Array for structure input & initiate structure
printf("\nEnter up to 50 numeric characters of data.\n");
scanf("%s", list[x].data);
所有的幫助是有用的,我提前感謝你。
從什麼寫這樣的代碼將停止嗎?什麼似乎很難? –
我目前在大學攻讀C,所以我不是100%的C語言高效。我對我想做什麼有了一些想法,但並不知道如何去做。 – user3103598