If you are currently a student from some college and studying computer science, you have to have an integrated development environment (IDE) to do your HW or to practice some coding on your computer. Many colleges might require students to use CodeBlocks, Visual Studio, or any other IDE because some college do not even provide iOS devices like an iMac. However, if you are a Mac user, using CodeBlocks or others might be uncomfortable for you. Additionally, you might have considered how to use Xcode, but there are some tricky parts in how to use Xcode. Some of my friends also gave up using Xcode because of that even they are Mac users. I have personally been using Mac for a while, so in this article, I am talking about how to input file for C++ in Xcode for people who are stuck on it.
First of all, you open the text editor you have on your Mac.
I personally use a text editor called Atom from Github.
At this time, I use these data. You can use any kinds of data in the file. After you put some data in the file, press “Command + S.” Then, you can save your file anywhere you want. In this article, I saved the file on the desktop because it is easy to find it out.
Next, here is the trickiest part and different from any other IDE.
- Go to your Xcode and follow some requirements from Xcode.
- After you get that window you can code, there are 2 icons that look like file on the left side. One of them is the name of the file you set up. And another one is named “product”
- When you click on that, a little another icon comes up and the name is exactly same as the name of the first file you set up.
- Right click on that icon, and click on “Show in Finder”
5. Drag the file to the place like the image.
If you get these steps done correctly, let’s get started with coding!
Here is what I code simply.
using namespace std;
inputFile.open("data.txt"); // The name of the file you set up.
while(inputFile >> countries)
cout << countries << endl;
You do not have to code same as mine.
Finally, let’s run it!
Mine is working well! How about yours?
If you have any question, put the comments below!