Simple Question

Im new to using xcode. In windows programming, i wouuld use the include directory #include "std_lib_facilities.h". What is the include directory for xcode? So confused cause ive been having to type
1
2
3
4
5
6
7
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
inline void keep_window_open() {char ch; cin>>ch; }


every time i have to do a new project.
Is there anyway i could simplify that> Thanks.
It isn't Xcode's problem -- you should be executing command line applications from the command line. (I will agree, however, that IDE's that are too stupid to launch your command-line application and not keep the window open when it terminates are obnoxious.)

Keep the console open long enough to see your program's output
http://www.cplusplus.com/forum/articles/7312/

...which was spawned from Console Closing Down
http://www.cplusplus.com/forum/beginner/1988/

The POSIX stuff should work for you.

One good way to do it is simply to have a global 'pause' function in your main file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <limits>
#include <string>
using namespace std;

struct PressEnterToContinue
  {
  ~PressEnterToContinue()
    {
    cout << "Press ENTER to continue..." << flush;
    cin.ignore( numeric_limits <streamsize> ::max(), '\n' );
    }
  }
  _;

int main()
  {
  cout << "Hello world!\n";
  return 0;
  }


Hope this helps.

[edit] I should note, however, that this isn't a panacea to keeping your window open. It might be better to find some system QUIT message you can capture that will let you know that it is time to hold the window.
Last edited on
Topic archived. No new replies allowed.