#if defined (_UNICODE) || defined (UNICODE)
#error "Unicode not supported - use Multi-Byte Character Set"
#endif
#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include <sstream>
usingnamespace std;
string n, f1, flf, f2;
stringstream ss;
string InitialDir;
int main (void)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
flf = "*.*";
cout<<"Enter file's location: "<<endl;
cin >> f1;
if (f1 == "music")
{
f1 = "C:\\Users\\cosmi\\Desktop\\Music\\";
}
InitialDir =f1 + flf;
printf ("Initial directory: %s", InitialDir.c_str());
hFind = FindFirstFileA (InitialDir.c_str(), &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Error: %lu ", GetLastError ());
system ("pause");
return EXIT_FAILURE;
}
do
{
printf ("\nFile: %s", FindFileData.cFileName); //If theres more files, i dont know how to make looking like: File 1: document.dox File 2: notes.txt ...
} while (FindNextFileA (hFind, &FindFileData));
FindClose (hFind);
cout<<" \n \nWhich you want to run?"<<endl;
cin >> n;
ss << "start " << f1 << n; //There's the problem, if i say n its "Spag Heddy - It's me.mp4" it will took only "Spag", why?
system (ss.str().c_str());
return 0;
return EXIT_SUCCESS;
}
You need to combine the answers given by Moschops with the one I gave. Mine was only half a solution, the part needed to get the following getline to work.