Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:32:11+00:00 2026-06-05T22:32:11+00:00

This is my method which is called when I click on a button in

  • 0

This is my method which is called when I click on a button in my C# GUI program. It launches a very simple C++ console program that does nothing but prints out a line every second in a never ending loop.

private static Process process;

private void LaunchCommandLineApp()
{
    process = new Process();
    process.StartInfo.FileName = "SimpleTest.exe";
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.EnableRaisingEvents = true;
    process.StartInfo.CreateNoWindow = false;
    process.OutputDataReceived += process_OutputDataReceived;

    process.Start();
    process.BeginOutputReadLine();
}

This is the method to handle any output data received:

private void process_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
    if (e.Data != null)
        Console.WriteLine(e.Data.ToString());
}

I do not see any output in my C# debug output…
But if i change the printf to std::cout, it will show the redirected message.

I am thinking if there’s any way to show those statements using printf ?

FYI: my c++ code [EDITED working version]:

#include <stdio.h>
#include <Windows.h>
#include <iostream>

int main()
{
int i = 0;

for(;;)
{
    Sleep(1000);
    i++;
    // this version of printf with fflush will work
    printf("The current value of i is %d\n", i);
    fflush(stdout);

    // this version of cout will also work
    //std::cout << "the current value of i is " << i << std::endl;
}

printf("Program exit\n");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:32:14+00:00Added an answer on June 5, 2026 at 10:32 pm

    Thanks guys for all your inputs!

    I think I would change all my printf to std::cout and std::endl for my C++ console program.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This button click method launches a Window called (assemblyname).Reports when a button with Content
Let's say I want a method which will be called like this: tiger =
I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true); . So this
I have this method which does certain checks and applies a color code on
I have a button and onclick is set to this method which should display
I have an AuthorizationServlet which is called when user click button in login page.
I have this method which lets me translate the position of an object, animating
I have this method which leaks ~ 6KB : + (EInspectorFacilityInfo*) newWithNode: (CXMLNode*) node
I have this method which will remove all rows from a table but I
So I have this method which will take an ArrayList of Integers, I compare

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.