obviously not the proper way.

i know theres a smarter way to do this but this is basic idea of what i want to do. which is to search the system for a file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>


using namespace std;

int main()
{
    string keyword;
    string search = "dir /s /a /b ";

cout << "Please enter the name of a file to search for.\n\n> ";
    getline(cin,keyword);
        system("CLS");
            system(search keyword);
        cout << "Searching, please wait..." << endl;
}
Is that a proprietary library or third party?
Third party. Worth the install, it's useful for a ton of things.
http://www.boost.org/
why does everyone keep using std::cout instead of just including using namespace std and just typing cout
Because it pollutes the global namespace with heaps of stuff, making variable name clashes more likely.

It probably won't affect your program but it is good practice to either put std:: before each std thing, or put using statements like this:

1
2
3
4
using std::cout;
using std::cin;
using std::endl;
//similar for all other std things 


I do a mixture, the above using statements for things that are used frequently, and std:: for other things that only used a couple of times, like std::find or std::sort say.

HTH
Topic archived. No new replies allowed.