4
我希望我在這裏不要求太多。在Objective-C中編寫一個命令行工具,它接受輸入,清除屏幕然後輸出
我想創建一個命令行工具,它將在終端窗口中運行。它將從終端獲取輸入,對字符串進行一些操作,清除屏幕然後輸出字符串。
#import <Foundation/Foundation.h>
#include <stdlib.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Running....");
// take the argument as an NSString
// do something with the NSString.
// clear the terminal screen.
// output the manipulated screen.
[pool drain];
return 0;
}
這可能嗎?有小費嗎?我想盡可能在Objective-C中編碼。
感謝,
EDIT 1 *
只是要清楚,我想連續輸入和程序輸出。換句話說,在可執行文件開始運行之後,有必要輸入數據。不只是最初執行時。
你總是可以調用'EXEC( 「在/ usr/bin中/清除」);'清屏。要接受輸入,可以使用任何C或C++方法,例如'fscanf()'或'std :: cin'。 – user1118321 2012-01-17 14:29:56