나는 사용자가 이름, 근무 시간 및 시간당 급여를 입력하는 학교용 프로그램을 작성 중입니다.fgets() 생략 된
int main()
{
char name[SIZE];
char selection = 'Z';
int hoursWorked = 0,
counter = 0,
flag = 1;
float hourlyRate = 0.0;
const float otRate = 1.5;
const int week = 40;
while (flag == 1)
{
system ("cls");
printf ("\n\tP A Y R O L L P R O G R A M\n");
printf ("---------------------------------------------\n");
printf ("\t(A) - New Payroll Info\n\t(B) - Display Payroll\n\t(C) - Quit\n\t");
scanf (" %c", &selection);
selection = toupper (selection);
switch (selection)
{
case 'A':
system ("cls");
printf ("Enter Employee Name: ");
fgets (name, SIZE, stdin);
strip_newline(name, 50);
printf ("\nEnter Hourly Rate: ");
scanf ("%f", &hourlyRate);
printf ("\nEnter Hours Worked This Week: ");
scanf ("%d", &hoursWorked);
system ("pause");
break;
크기는 50이며, STDIO.H & stdlib.h 포함된다. 컴파일하고 A 스위치로 이동하면 fgets()
입력을 건너 뛰고 "Enter Hourly Rate: "
scanf()
으로 바로갑니다. fgets()
앞에 scanf()
을 넣어 주문 변경 시도를했지만 아무 소용이 없습니다.
[the c-faq] (http://c-faq.com/)의 12 절을 읽으십시오. 그리고 여러분이 이미 있기 때문에, 다른 섹션들도 읽어보십시오 :-) – pmg