K
K
Kryptylogy2019-11-18 10:08:39
C++ / C#
Kryptylogy, 2019-11-18 10:08:39

How to open a file using C++?

I want an elementary bat file :

@echo off 
start 333.png

convert to exe.
That is, I just need a program that would open some file, for example:
mp3,mp4,jpg,png,exe,bat.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Roman, 2019-11-18
@myjcom

#include <string>
int main(int argc, char* argv[])
{
  std::string cmd = "start ";
  if(argc > 0)
  {
    cmd += argv[1];
  }
  system(cmd.c_str());
}

programm.exe filename

A
Armenian Radio, 2019-11-18
@gbg

Batnik is not needed. The analogue of your "start bullshit.png" would be a WinApi ShellExecute call

A
Artem @Jump, 2019-11-18
curated by the

If you run the executable then -

and the
@echo off
start 333.png command was executed there

The 333.png file does not appear to be an executable file by its extension. How do you want to open it?
In binary form, for reading or for writing? Or do you want to open it in a graphics editor? Or where else?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question