thầy ơi!
sao hàm system (“cls”); khi đặt trong vòng lặp do while thì nó ko chạy case 2 và case 3 dc ạ. thầy check giúp em với ạ.
# include
# include
#include
int menu();
int menu() {
printf(“\t*************************************************\n”);
printf(“\t*Date of examination: *\n”);
printf(“\t*Student name: Tran Hoang Quang Hien *\n”);
printf(“\t*Student number: SE160126 *\n”);
printf(“\t*batch: 06 *\n”);
printf(“\t* —————MENU————– *\n”);
printf(“\t*Please select the number for appropritate tasks*\n”);
printf(“\t*1. Quit program. *\n”);
printf(“\t*2. Question 2. *\n”);
printf(“\t*3.Question 3. *\n”);
printf(“\t* *\n”);
printf(“\t*************************************************\n”);
printf(“\t\nInput a number to run its procedure : “);
fflush(stdin);
getchar();
}
int main() {
int choice;
do
{
choice = menu();
switch (choice)
{
case ‘1’:
system(“cls”);
printf(“\n\n the program is exiting…\n\n”);
break;
case ‘2’:
system(“cls”);
printf(“Question 2 is:”);
break;
case ‘3’:
system(“cls”);
printf(“question 3 is :”);
break;
default:
system(“cls”);
printf(“\n\n ERROR!! you input is invalid!\nPlease, try again…\n\n”);
system(“pause”);
}
int main() {
int choice;
do
{
menu();
scanf("%d", &choice);
switch (choice)
{
case 1:
system("cls");
printf("\n\n the program is exiting...\n\n");
break;
case 2:
system("cls");
printf("Question 2 is:");
break;
case 3:
system("cls");
printf("question 3 is :");
break;
default:
system("cls");
printf("\n\n ERROR!!you input is invalid!\nPlease, try again...\n\n");
system("pause");
}
} while (choice != 1);
system("pause");
return 0;
}
thầy ơi, cho em hỏi là hàm nhập getch() em sử dụng để giải bài tập nhập mật khẩu mà không hiển thị mật khẩu mình nhập mà thay thế bằng kí tự ‘X’, cơ mà em sử dụng hàm đó trên Visual lại không được ạ, có cách nào fix không thầy?
5 Comments
thầy ơi!
sao hàm system (“cls”); khi đặt trong vòng lặp do while thì nó ko chạy case 2 và case 3 dc ạ. thầy check giúp em với ạ.
# include
# include
#include
int menu();
int menu() {
printf(“\t*************************************************\n”);
printf(“\t*Date of examination: *\n”);
printf(“\t*Student name: Tran Hoang Quang Hien *\n”);
printf(“\t*Student number: SE160126 *\n”);
printf(“\t*batch: 06 *\n”);
printf(“\t* —————MENU————– *\n”);
printf(“\t*Please select the number for appropritate tasks*\n”);
printf(“\t*1. Quit program. *\n”);
printf(“\t*2. Question 2. *\n”);
printf(“\t*3.Question 3. *\n”);
printf(“\t* *\n”);
printf(“\t*************************************************\n”);
printf(“\t\nInput a number to run its procedure : “);
fflush(stdin);
getchar();
}
int main() {
int choice;
do
{
choice = menu();
switch (choice)
{
case ‘1’:
system(“cls”);
printf(“\n\n the program is exiting…\n\n”);
break;
case ‘2’:
system(“cls”);
printf(“Question 2 is:”);
break;
case ‘3’:
system(“cls”);
printf(“question 3 is :”);
break;
default:
system(“cls”);
printf(“\n\n ERROR!! you input is invalid!\nPlease, try again…\n\n”);
system(“pause”);
}
} while (choice!=1);
system(“pause”);
return 0;
}
e làm như sau:
================
thầy ơi sao ví dụ này e chạy lỗi vậy ạ
#include
int main() {
char s[10];
printf(“%s”, “Enter a string: “);
scanf(“%9[aeiou]”, s);
printf(“s = \”%s\””, s);
return 0;
}
Với câu 2 phần bài tập nhập a[0] xong nó nhảy luôn đến a[2] vậy ạ
E nhập chuỗi bắt đầu với các kí tự nguyên âm nó mới ra kết quả nhé. nếu không nó hiện chuỗi giá trị rác, không phải lỗi
thầy ơi, cho em hỏi là hàm nhập getch() em sử dụng để giải bài tập nhập mật khẩu mà không hiển thị mật khẩu mình nhập mà thay thế bằng kí tự ‘X’, cơ mà em sử dụng hàm đó trên Visual lại không được ạ, có cách nào fix không thầy?