Author Topic: Terminal to launch consol programs is grayed and not working  (Read 5650 times)

Offline hamid

  • Single posting newcomer
  • *
  • Posts: 2
Terminal to launch consol programs is grayed and not working
« on: November 28, 2024, 09:38:33 am »
Hello,

I would like to have console to be opened and view during running the program, but I cannot see how to do it.
Can anybody suggest what should be done about the above problem.
Thank you,
Hamid

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Re: Terminal to launch consol programs is grayed and not working
« Reply #1 on: November 28, 2024, 06:40:10 pm »
Click MainMenu/Project/Properties/BuildTargets.
Select the build target you are going to run.
Change the type to "Console Application" and rebuild.

Offline hamid

  • Single posting newcomer
  • *
  • Posts: 2
Re: Terminal to launch consol programs is grayed and not working
« Reply #2 on: December 03, 2024, 08:22:53 am »
Thank you for your response. I would like to keep the console windows open all the time when I am working on a project.

Could you please let me know how can it be done.

Regards,

Hamid

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Re: Terminal to launch consol programs is grayed and not working
« Reply #3 on: December 04, 2024, 06:39:13 am »
Thank you for your response. I would like to keep the console windows open all the time when I am working on a project.

Could you please let me know how can it be done.

Regards,

Hamid

I'm confused by this request. A console is either a stand-alone process that belongs to no project, or it is a console attached to a running project that takes input for the running project and accepts output from the running project.

How do you expect a console to be attached to a non-running project that you are working on?

If all you want is a console that is running on it's own behalf, in Windows, hit the windows key+r and type "cmd".

If you want a console attached to a process to accept input and produce output to the a console, write a program that reads (see reading from stdin) from a console and write output to the console (see writing to stdout).

Google "c++ stdin and stdout and stderr"

In C++, stdin, stdout, and stderr are standard input, output, and error streams, respectively. They allow you to interact with the console.
Here's a breakdown:

    stdin:
    Represents the standard input stream, typically connected to the keyboard. You can use it to read input from the user.
    stdout:
    Represents the standard output stream, typically connected to the console window. You can use it to write output to the console.
    stderr:
    Represents the standard error stream, typically connected to the console window. You can use it to write error messages to the console.

How to use them:

    cin: The cin object is used to read input from stdin.
    cout: The cout object is used to write output to stdout.
    cerr: The cerr object is used to write error messages to stderr.

Example:
C++

#include <iostream>

int main() {
    int number;

    // Read input from stdin
    std::cout << "Enter a number: ";
    std::cin >> number;

    // Write output to stdout
    std::cout << "You entered: " << number << std::endl;

    // Write error message to stderr
    std::cerr << "This is an error message!" << std::endl;

    return 0;
}

Important points:

    You need to include the <iostream> header to use these streams.
    cin, cout, and cerr are objects of classes istream, ostream, and ostream, respectively.
    You can use the >> operator with cin to read different data types.
    You can use the << operator with cout and cerr to write different data types.
    You can redirect these streams using the <, >, and 2> operators in the command line.
 
« Last Edit: December 04, 2024, 06:45:18 am by Pecan »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Terminal to launch consol programs is grayed and not working
« Reply #4 on: December 05, 2024, 07:16:10 am »
The OP might want to look at the ToolPlus CB Plugin.

Tim S.
« Last Edit: December 05, 2024, 07:26:09 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org