I have made a python program which will create an OpenGL and render a teapot (GLUT standard teapot) with a shader that I specify. The shader is specified as follows:

  • I have a file called "index.ini" which contains the file paths to a vertex shader and pixel shader file
  • The program gets the contents of "index.ini" using "sys.argv[1]"
  • I run the program from CMD with the following: "test.py index.ini"

I want to be able to right click on "index.ini" and open it by default with a C++ program, which will get the path to "index.ini" through "argv" and pass it to CMD, where I can make a call such as "test.py index.ini", using "system()". I have tried the following, but the program just hangs and then crashes.

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(char *argv[])
    string toCall="<PATH>\\test.py ";
    string file=argv[1];
    string finalCall = toCall + file;

Thanks :)

6 Years
Discussion Span
Last Post by SgtMe

Your main() does not have the proper signature for taking arguments, you want to have ..

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

int main(int argc, char *argv[])

You might also want to check that argc is equal to (at least) 2.

Votes + Comments
Danke schon :D
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.