c++ - 代码 4 : file as command argument

标签 c++ xcode command-line command-line-arguments

如何在 Xcode 4 中将文件作为 C++ 文件的参数? 现在,当我运行我的项目时,我必须在终端中使用:

g++ mainFile.cpp -o main.out < inputfile.txt

我希望能够在 XCode 中执行“<inputfile.txt”部分,以便我可以使用调试器等。

在我的代码中,我像这样通过 cin 使用输入文件:

cin>>dim; 

for (int i =0; i<dim; i++) {
    for (int j =0; j<dim; j++) {
        cin>>A[i][j];
    }
}

我正在学习 C++ 初学者类(class),因此代码必须如此。我非常想在 XCode 中运行它!谢谢

最佳答案

阅读 CedricSoubie 对以下 Stack Overflow 问题的回答:

How do you specify command line arguments in Xcode 4?

关于c++ - 代码 4 : file as command argument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6088333/

相关文章:

ios - 如何解决 Swift 3 中的键盘问题?

java - 在 Java 中获取特定进程的 CPU 使用率的正确命令行是什么

php - 如何将 PHP 脚本转义到外部编辑器并在之后返回?

c++ - 找不到 Sphinx Ubuntu 14 c++ sphinx_config.h

c++ - 错误 LNK2019 : unresolved external symbol linker can't find dll

c++ - 如何将 vector 拆分为 n 个 "almost equal"部分

ios - 使用 Autolayout Visual Format Language 将 UIViews 排成一行

c++ - 运行 OpenCV 3.1 迷你应用程序时出现蓝屏

iphone - Fetch 忽略 "entity"指定 - iOS 上的 CoreData - 返回错误的实体

macos - 如何在 mac 上用 tab 替换多个空格