运行C脚本与终端的不是X code [英] Running C scripts with terminal instead of Xcode

查看:136
本文介绍了运行C脚本与终端的不是X code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我开发了几个C程序对利用X code我的Mac。然而,有1的问题。我的学习要求我通过编码来使用某种输入栏。因此,例如,如果用户想要以运行该程序的10倍或希望程序来创建10的答案。我使用的atoi(ARGV [1])只是为了获取用户输入。

Currently I am developing a couple of C programs on my mac using Xcode. There however is 1 problem. My study requires me to use some sort of input field through the coding. So for instance if the users wants to run the program 10 times or wants the program to create 10 answers. I am using "atoi(argv[1])" just to get the input from the user.

这正是问题。当我运行程序,它只是开始的错误,这是正常的我quess,因为他正在等待输入,而不是接受它或别的东西。反正我试图解决这个问题,此链接:<一个href=\"http://stackoverflow.com/questions/7780301/how-to-run-command-line-application-from-the-terminal\">How从终端中运行命令行应用程序?

This is exactly the problem. As soon as I run the program it just starts to bug, which is normal I quess because he is waiting for the input and not receiving it or something else. Anyways I tried to solve this problem with this link: How to run command-line application from the terminal?

这不幸剪掉解决它的。我已经尝试重新安装X code,因为只是在我的终端不工作进入GCC要么,但每次在App Store自动instals对我来说。

This unfortunately didnt solve it either. I have already tried to re-install xcode, because just entering gcc in my terminal doesnt work either, but everytime the app store auto instals it for me.

有没有人有我的问题修复。我将不胜AP $ P $它pciate归因于下周五我有其他期限:(我不会得到一个足够的等级,如果我的用户输入不正常的事实。

Does anyone has a fix for my problem. I would greatly appreciate it due to the fact that next friday I have another deadline :( and I wont be getting a sufficient grade if my user input is not working.

您的帮助是再多AP preciated!

Your help is again much appreciated!

问候,

Kipt Scriddy

Kipt Scriddy

编辑:为了澄清这个问题。当运行我希望它在终端和羯羊弹出脚本有一个输入字段reguired它应该要求输入。目前,他正在崩溃立刻由于缺乏投入。他不是等待参数从用户传递。他跳过部分

To clarify the problem. When running the script I want it to pop up in Terminal and wether there is an input field reguired it should ask for input. At the moment he is crashing immediatly due to the lack of input. He is not waiting for the argument to be passed from the users. He is skipping that part

推荐答案

根据X code IDE HOWTO传递的命令行参数程序

HOWTO Pass command line arguments to your program from Xcode IDE


  1. 打开你的项目的活跃的计划。要做到这一点最简单的方法是从主菜单。选择产品/方案/编辑计划...

  2. 在架构编辑器,你会看到在左侧几个构建目标;你想要的是在运行为yourprojectname目标。选择它。

  3. 在右侧你会看到四个子选项卡,包括信息,参数,选项和诊断。选择参数

  4. 添加/删除你需要的任何参数。在你的情况,添加 /披作为第一个参数,那么 10 作为第二。

  1. Open your project's active Scheme. Easiest way to do this is from the main menu. Select Product/Scheme/Edit Scheme...
  2. In the schema editor, you'll see several build targets on the left side; the one you want is the "Run YourProjectName" target. Select it.
  3. On the right side you'll see four sub-tabs, including Info, Arguments, Options, and Diagnostics. Select Arguments
  4. Add/Remove any arguments you need. In your case, add /phi as the first argument, then 10 as the second.

值得注意:这也是你可以在启动时指定你的程序的当前工作目录,而不是长期,临时路径X code栋二进制文件时使用。要做到这一点:

Noteworthy: This is also where you can specify the current working directory of your program at launch rather than the long, temp path Xcode uses when building your binaries. To do so:


  1. 从上面的执行步骤1-2。

  2. 选择选项子标签

  3. 点击使用自定义工作目录复选框。

  4. 指定要在其中X code到从执行程序的完整路径。

这是在得到您的参数处理固定在你的程序的组合应该得到你和运行。

That in combination with getting your parameter handling fixed in your program should get you up and running.

这篇关于运行C脚本与终端的不是X code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆