|
|
#1 |
|
Xcode 4, C++, Importing files?
Hey
I'm having trouble importing files into my C++ code: Code:
#include <iostream>
#include <fstream>
#include <assert.h>
#include <math.h>
#include "Matrix.h"
using namespace std;
int main() {
// Open File
string line;
ifstream myfile;
myfile.open("SizeImage.txt");
if (myfile.good())
{
while ( ! myfile.eof())
{
myfile >> line;
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file"<< endl;
return 0;
}
|
|
|
|
0
|
|
|
#2 | |
|
Quote:
Make sure you understand the concepts of working directory and relative pathname (which your code is using). http://en.wikipedia.org/wiki/Working_directory http://en.wikipedia.org/wiki/Path_(computing) There's no such thing as an "input folder" or "output folder" unless you write code that implements those ideas. To set the working directory in Xcode 4, try searching Xcode's builtin documentation for keywords working directory. You will need to edit the Scheme and set the Working Directory to the folder where your file resides. See this Xcode 4 reference doc, under the subheading "Run Your Application to Debug It": http://developer.apple.com/library/m.../Building.html See Figure 5-3. You might also use the C function getcwd() to confirm at runtime that the working directory is what you expect. For an example, see my replies here: http://forums.macrumors.com/showthread.php?t=1162921 EDIT (2013-02-12) The links originally given are broken (now in strikeout). Try this link: http://developer.apple.com/library/m...meProfile.html If When that breaks, try google search terms: xcode set working directory site:developer.apple.com This will search for the given words, confined to the site developer.apple.com. Last edited by chown33; Feb 12, 2013 at 11:52 PM. Reason: fix broken links |
||
|
|
0
|
|
|
#3 |
|
myfile.open("filepathhere/SizeImage.txt");
Will also work Also make sure you set xcode to compile in release, not debug mode. The GCC iostream debug libraries don't work very well (or at all sometimes). |
|
|
|
0
|
|
|
#4 |
|
Have you tried <cmath>? In C isnan is a macro, in C++ it's an overloaded function. Try cmath and see how it goes.
-Lee |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| Using C++ in XCode 4 - .out file? | ArtOfWarfare | Mac Programming | 7 | Dec 5, 2011 12:23 AM |
| Xcode 4.1 'Run' won't work.. | DoodlyDoo | Mac Applications and Mac App Store | 0 | Sep 26, 2011 09:49 AM |
| xcode 4/older vs netbeans vs eclipse vs yourRecommendation on the mac for C++ | neuroshock | Mac Applications and Mac App Store | 0 | Jul 4, 2011 05:09 PM |
| Facebook API and Xcode 4 | Berko | iPhone/iPad Programming | 4 | Mar 15, 2011 04:39 AM |
| Help Needed - Xcode 4 Options: Use Core Data Include Unit Tests | Mitch1984 | iPhone/iPad Programming | 3 | Feb 26, 2011 03:42 PM |
All times are GMT -5. The time now is 04:10 AM.







Linear Mode

