int main(int argc, const char * argv[])
{
if (argc != 2){
cout << "Usage: ./Sort <file_name>" << endl;
return EXIT_FAILURE;
}
//and so on
}
How can I run this program using Xcode? I have made an Xcode project, this .cpp file is part of it.
How can I pass an argument to the program when I run it using Xcode.
First, create your project as a command line tool under Mac OS X project. Select C++ as the language. Voila, you can now enter your c++ code and run it.
To pass arguments, select the Product menu, Scheme menu item, edit scheme. Select the Run icon on the left side and the arguments tab. There you can set arguments to be passed in on launch.