如何删除字符串后的新行

我试图使用结构数组和代码打印字符串和整数似乎很好,但是在输出而不是1行值中,在每个字符串之后自动添加新行。有人可以帮忙吗?

#include <stdio.h>

typedef
    struct player_main{
        char name[20];
        int total;
    }
player;

void print(player pprint);
void scan(player *pscan);

int main(){
    player user[2];
    for(int i = 0; i < 2; i++){// scanned
        printf("Player %d", i+1);
        scan(&(user[i]));
    }
    for(int i = 0; i < 2; i++){// printed
        print(user[i]);
    }

    return 0;
}
void print(player pprint){
    printf("%s Weight:%d kg\n", pprint.name, pprint.total);

}
void scan(player *pscan){
    printf("\nName: \n");
    fgets(pscan->name, 20, stdin);
    printf("\nEnter weight:");
    scanf("%d%*c", &(pscan->total));

} 

所需输出示例:

Player A, 50 kg    Player B, 60 kg

实际输出:

Player A,
50 kg
Player B,
60 kg
评论