Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
Why can not pass the compile for the program below, using OnlineGDB. It can pass on Dev-c++.
+2
votes
asked
Mar 21, 2020
by
童翰昇
(
140
points)
#include <conio.h> //getch()、getche()需要
#include <stdlib.h> // system()需要
#include <stdio.h> //putchar()需要
int main()
{
char ch;
int ch_ascii;
do{
ch=getch();
putchar(ch);
}while(ch!='A'); // 輸入字元"A"結束重複結構
printf("\n"); //換列
do{
ch=getche();
putchar(ch);
}while(ch!='A'); // 輸入字元"A"結束重複結構
printf("\n\n"); //換列
system("pause");
return 0;
}
getch
getche
onlinegdb
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
2 Answers
0
votes
answered
Mar 25, 2020
by
Alan Sampson
(
440
points)
You coded getche() instead of getch() in the second do loop.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
0
votes
answered
Mar 25, 2020
by
Alan Sampson
(
440
points)
Another consideration: OnlineGDB runs on Linux. What are the chances a call to system("pause") will work on Linux? There is no pause command in Linux, the program probably won't work even if you do get it to compile.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...