C语言不换行输入

Python014

C语言不换行输入,第1张

把逗号去掉,在输入时用空格间隔开 。而且scanf语句中不能出现\n根据你给的代码我改进后如下:#include<stdio.h>#include<malloc.h>typedef struct Node{ char num[11]char name[20]int englishint mathint foreignstruct Node *next}studentint main(void){ student *p1,*p2p1 = (student *)malloc(sizeof(student))printf("请输入:学号 姓名和英语 数学 外语成绩(输入学号为0时输入完毕)\n")scanf("%s %s %d %d %d",&p1->num,p1->name,&p1->english,&p1->math,&p1->foreign)p1->next=NULLprintf("该学生的资料为:\n")printf("学号:%s,姓名:%s,英语:%d,数学:%d,外语:%d\n",p1->num,p1->name,p1->english,p1->math,p1->foreign)free(p) return 0}这是效果图。团队刚开始发展,希望给予点支持。谢谢

不同的系统甚至不同的编译器,对光标的控制方法是不同的,这个不是C的功能,而是系统的功能数据换行并不影响程序的使用,所以一般我们不关心它,在windwos下,要使光标移动到上一行,可用API函数void gotoXY(int x, int y){ //Initialize the coordinates COORD coord = {x, y} //Set the position SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord)}而纯DOS中,TC有gotoxy(int x,int y)函数的但这些在实际应用中根本用不到,因为现在开发程序都是基于windwos窗口的了

int main()

{

char ch

while(scanf("%c",&ch)!= '\n')

putchar(ch)

return 0

}

你把/n 去掉就好了,具体原因 估计是因为换行符导致的。