Thread: Need help with System() and putting into function. --New to C++

  1. #1
    JosephDiPerla
    Guest

    Question Need help with System() and putting into function. --New to C++

    Hi there. Let me display my code first:

    void RunExtFile(char filelocation) {
    int system(filelocation);
    }

    Basically, I am trying to create a function RunExtFile(), everytime I put this in my code, it should be able to shell or execute a command. EG:

    RunExtFile("C:\\Email.exe");

    and it will launch email.exe. How can I get it to work? What am I doing wrong? Is there something else I can use to shell a program?

    I am using Visual c++ 6.0 on windows 98 SE.

    JD

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Ditch the int in front of "system" and make the parameter a char pointer and it should work. You should make this an inline function

    Code:
    inline
    void RunExtFile(char *filelocation) {
        system(filelocation);
    }

  3. #3
    JosephDiPerla
    Guest

    thanks

    Cool, thanks! I will try it out now. Thanks for your time.

    JD

  4. #4
    JosephDiPerla
    Guest

    Sorry

    Sorry but this is the error I get when doing that:

    C:\joey\ags\ags_template.cpp(84) : error C2065: 'system' : undeclared identifier
    Error executing cl.exe.

    Any idea why I get that? I have included these files:
    windows.h
    iostream.h
    dos.h

    JD

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793

    Re: Sorry

    Originally posted by JosephDiPerla
    Sorry but this is the error I get when doing that:

    C:\joey\ags\ags_template.cpp(84) : error C2065: 'system' : undeclared identifier
    Error executing cl.exe.

    Any idea why I get that? I have included these files:
    windows.h
    iostream.h
    dos.h

    JD
    #include <stdlib.h>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  2. System Tray
    By Sucur in forum Windows Programming
    Replies: 8
    Last Post: 05-08-2006, 09:33 AM
  3. putting variables together in system
    By bluehead in forum C++ Programming
    Replies: 16
    Last Post: 08-18-2003, 05:09 PM
  4. Putting variables in SYSTEM
    By mycro in forum C++ Programming
    Replies: 3
    Last Post: 05-29-2003, 07:59 PM
  5. bind() system call
    By threahdead in forum C Programming
    Replies: 4
    Last Post: 01-14-2003, 09:08 AM