相关疑难解决方法(0)

什么`scanf("%*[^ \n]%*c")`是什么意思?

我想在C中创建一个循环,当程序要求一个整数并且用户键入一个非数字字符时,程序再次请求一个整数.

我刚刚找到了以下代码.但我不明白这意味着什么scanf("%*[^\n]%*c").什么^\n意思?什么是*之前^\nc意味着什么呢?

/*

 This program calculate the mean score of an user 4 individual scores,
 and outputs the mean and a final grade
 Input: score1, score2,score2, score3
 Output: Mean, FinalGrade

*/
#include <stdio.h>
//#include <stdlib.h>

int main(void){
  int userScore = 0; //Stores the scores that the user inputs
  float meanValue = 0.0f; //Stores the user mean of all the notes
  char testChar = 'f'; //Used to avoid that the code …
Run Code Online (Sandbox Code Playgroud)

c user-input scanf format-specifiers

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

c ×1

format-specifiers ×1

scanf ×1

user-input ×1