Comp Sci Can console commands like cin, cout, getch, etc be used in windows apps?

  • Thread starter Thread starter Pipsqueakalchemist
  • Start date Start date
AI Thread Summary
Using console commands like cin and getch in Windows applications can lead to issues, particularly with blocking the event loop. These commands are designed for console applications and do not integrate well with event-driven GUI frameworks, causing problems when trying to exit loops. The discussion emphasizes that blocking I/O operations are generally incompatible with GUI applications, which are built to handle user input through graphical elements. It is suggested to focus on learning the fundamentals of Windows GUI programming to address these challenges effectively. Understanding the appropriate structure for GUI applications is essential for solving common programming problems.
Pipsqueakalchemist
Messages
138
Reaction score
20
Homework Statement
can I used console commands in windows application?
Relevant Equations
C++, visual studio
So I started working in a windows application. But i started having issues with blocking the event loop when using while loops that i never encountered before when using while loops in console application.

My theory is that I used commands like getch or cin to exit the loop in the window application and that those commands work fine in console but not in windows and that's why I can't exit my while loops and my event loop is blocked

Is this the case because if it's not then I'm at a complete loss because I've never encountered these issues before when coding in console.
 
Physics news on Phys.org
You kind of let your other thread with this question just hang there.

But to repeat some from that thread: as a rule of thumb you cannot in general expect that blocking I/O and event driven applications mix well. Waiting for user input using cin in GUI application seems particularly weird and pointless since the GUI is there to handle user input with framework elements like buttons and text fields/areas. Perhaps you can describe what kind of problem you are trying to solve and what makes you want to mix console and GUI functions?

It will probably also be a good idea you learn the basics of (Windows) GUI programming and how to structure such an application to solve "standard problems".
 
  • Like
Likes Tom.G and Mark44

Similar threads

Replies
10
Views
3K
Replies
6
Views
3K
Replies
2
Views
9K
Replies
5
Views
2K
Replies
6
Views
4K
Replies
1
Views
2K
Replies
4
Views
8K
Back
Top