[英]how do return a file line number in C, so that I can use a for loop to printf() a sequence of lines from the file?
[英]How can I use printf command at C so that it appears only a specific number of digits or characters?
我必須編寫一個程序,該程序“讀取”一個字符串,一個整數和一個浮點數。 然后,使用printf()
命令,每個輸入必須至少出現3個字符,但不超過7個字符或數字。 如何做到這一點?
您可以使用fgets限制從鍵盤輸入中讀取的字符。 嘗試這個:
char string[7];
fgets(string, sizeof(string),stdin);
printf("%s\n",string);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.