Help needed regarding System() in C

Discussion in 'C' started by vikky1988i, Jun 16, 2011.

  1. vikky1988i

    vikky1988i New Member

    Joined:
    Apr 1, 2010
    Messages:
    25
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Mainframes Admin. @ I | Nautix Technologies
    Location:
    chennai , Tamil Nadu ,INDIA
    Hello ,
    Good evening all .

    I have a query , how to open notepad files already saved in the memory...... or PPT or Docs. Though system() is there in C , but it invokes .EXE files only ..

    (.i.e) if i have a notepad named : SRV.txt.. how to open it using System() which opens a Notepad window to SRV.txt????

    Please help :smug::smug: , I have tried searching in NET , but it failed.
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Two solutions.
    (1) you can call system("notepad.exe srv.txt"); which should do the trick (you may need to add paths into that).
    (2) (I think) you can use one of the WinExec functions to invoke srv.txt, which will look up what application is associated with srv.txt and launch it with srv.txt as the first parameter.

    system("srv.txt") definitely won't work though. As you correctly observe, system() is for executables only.
     
  3. vikky1988i

    vikky1988i New Member

    Joined:
    Apr 1, 2010
    Messages:
    25
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Mainframes Admin. @ I | Nautix Technologies
    Location:
    chennai , Tamil Nadu ,INDIA
    Thanks alot , i got ur's :)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice