CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2009
    Posts
    37

    reading a content of a text file

    How to write a program to read a content of a text file.
    Actually i need to create a front end for a C program.
    By clicking a button, it should call the .exe of the c program and displays the output of the program which is present in .txt file.

    Can anyone guide me to write this program

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: reading a content of a text file

    See CreateProcess() Windows API for creating a new process (running your executable). Then, for displaying the text file, well, that depends on the way you want to display it. For instance you can run notepad.exe providing the path as an argument. Or you can display it in your own application. So you have to explain more.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Mar 2009
    Posts
    37

    Re: reading a content of a text file

    Thanks for ur reply.I hav some more doubts.
    Is it possible to use system command in VC++.
    I have to execute/open a command prompt to execute a c file from a button click.
    Is it possible to do this using createprocess

  4. #4
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: reading a content of a text file

    You can't execute a c file. You need to compile it first.

    With ShellExecuteEx combined with WaitForSingleObject you can execute a exe file and wait for it to end.

  5. #5
    Join Date
    Mar 2009
    Posts
    37

    Re: reading a content of a text file

    k...Is it possible atleast to open the exe.

  6. #6
    Join Date
    Mar 2009
    Posts
    37

    Re: reading a content of a text file

    I hav been asked to execute a C program from VC++ program using buttonclick event.
    Is it possible to do this?

  7. #7
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: reading a content of a text file

    Yes, but it has to be compiled first. The you can run the executable with CreateProcess(). What's not clear?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  8. #8
    Join Date
    Mar 2009
    Posts
    37

    Re: reading a content of a text file

    K...Is it not possible to compile it in VC++.
    How to use CreateProcess in VC++.

  9. #9
    Join Date
    Mar 2009
    Posts
    37

    Re: reading a content of a text file

    I hav got the result for this

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured