我的問題看起來很簡單,我很抱歉問,但是這個代碼有什麼問題?爲什麼只是跳過名字部分?爲什麼我的「獲取」函數不能真正得到一個字符串?
#include <stdio.h>
#include <conio.h>
#include <string.h>
#define nl printf("\n")
struct date{int day,month,year;};
struct student{long int id;char name[30];struct date birthday;};
int main()
{
struct student temp;
nl;nl;printf("ID no:");scanf("%ld",&temp.id);nl;
printf("Student name:");
gets(temp.name);
nl;nl;
printf("Student birthday year:19");scanf("%d",&temp.birthday.year);nl;
printf("Student birthday month");scanf("%d",&temp.birthday.month);nl;
printf("Student birthday day");scanf("%d",&temp.birthday.day);nl;
getch(); //for pause
return 0;
}
獲取函數有什麼不對嗎?!因爲我不想使用scanf("%s",)
因爲空間的原因...
關於_「學生生日年:19」_,你寫這本世紀了嗎? – ryyker
我是一個新的程序員抱歉沒有知識... – amfad33
'#define nl printf(「\ n」)'是可怕的C,並且不應該在程序中。 – abelenky