File creation in C++ on Xcode

前端 未结 3 1685
半阙折子戏
半阙折子戏 2020-12-19 13:37

This is supposed to create a file in my project directory called \"tuna.txt\". When I run it, it compiles successfully, however no file is created. I am on a mac using xcode

3条回答
  •  [愿得一人]
    2020-12-19 14:07

    I assure you that barring errors (which you're not checking for) a file is created. Xcode has a tendency to use the final build-dir as the current working directory when running from the IDE. you can change this by editing the active Scheme.

    1. Click on the Project box to the right of the STOP button on the main toolbar
    2. Select Edit Scheme
    3. Select the "Run" sub scheme in the left pane list.
    4. Select the Options tab,
    5. Check the "Use Custom Working Directory" checkbox
    6. Set the working directory to some place you know (like your project root folder).

    Note: This is also where you will setup any command line arguments (those are on the Arguments tab, not the Options tab), should you desire to do so.

提交回复
热议问题