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

  • Comp Sci
  • Thread starter Pipsqueakalchemist
  • Start date
  • #1
Pipsqueakalchemist
130
18
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
  • #2
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

1. Can console commands like cin, cout, getch, etc be used in windows apps?

Yes, console commands like cin, cout, getch, etc can be used in Windows apps. However, it is important to note that these commands are typically used for console-based applications and may not work as expected in a graphical user interface (GUI) application.

2. Are there any limitations to using console commands in Windows apps?

While console commands can be used in Windows apps, there may be limitations in terms of functionality and compatibility with GUI applications. It is important to consider the specific requirements of your application before deciding to use console commands.

3. How can I use console commands in a Windows app?

To use console commands in a Windows app, you will need to include the necessary header files and libraries in your project. You can then use commands like cin and cout to read input from the user and display output to the console window.

4. Can I mix console commands with GUI elements in a Windows app?

While it is possible to mix console commands with GUI elements in a Windows app, it is generally not recommended as it can lead to a confusing user experience. It is best to choose either a console-based approach or a GUI-based approach for your application.

5. Are there any alternatives to using console commands in Windows apps?

Yes, there are alternative methods for handling input and output in Windows apps, such as using text boxes and labels in a GUI application. These methods are more suitable for applications that require a graphical user interface and may provide a better user experience than using console commands.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
3
Views
516
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Programming and Computer Science
Replies
2
Views
881
  • Engineering and Comp Sci Homework Help
Replies
6
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Computing and Technology
Replies
12
Views
2K
Back
Top