+ 1
what is wrong with my code?
hello everyone, can you tell me what is wrong with my code? after run,This message is displayed "Time limit exceeded" ! this code Separates the digits of the number entered and print them, thanx https://code.sololearn.com/cQEu61MIzmWq
5 Antworten
+ 3
that getch() you don't need that it keeps waiting for a keystroke and being online compiler it takes all input first.
So simple solution remove that getch() also then you can remove that conio.h header file
+ 8
Megatron
It's all about the difference between the real console/terminal (e.g CMD in Windows) and the console/terminal emulator (those on Web-based compilers except Cpp Shell, AFAIK) by which the compiler can communicate with a limited yet sufficient output screen. In addition to being sandboxed -- which won't allow the user to call certain system functions -- and restricted resource management, there are some other problems as the side-effect of those limitations are present like this one where the limited time span of the console emulator for processing the input is acts as a barrier (for users and attackers) but on the other hand saves the server's shared resources in order to respond to massive queries. Conversely, on a workstation, there's no worry about the system resources since the user as the system administrator has the total authority to ab/use them whenever needed.
+ 1
yep it is offline compiler that doesn't take input before executing program. it asks for input in real time and that getch() can be passed value at realtime which is not possible for online compilers in general.
0
Megatron thanx so much, the problem was solved,but i run that code in code block and it worked!
0
Megatron yeah, you're right,thank you so much 🙏☺️