Objective-C边学边记-2:统计文本文件中单词的长度
/* * 统计文本文件中单词的长度 * */ #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { FILE *wordFile = fopen("words.txt","r"); char word[100]; while (fgets(word,100,wordFile)) { //换行符修改为 '\0' word[strlen(word)-1] = '\0'; NSLog(@"%s is %d characters long", word,strlen(word)); } fclose(wordFile); return 0; }
如何自动复制文件words.txt到目标目录:
在Targets下面,右键项目名,Add New build Phase -> New Files Phase
目标选为Executables,然后把words.txt拖到刚才建立的"copy FIles (1)" build Phase
如何给调试项目添加命令行参数:
在Executables下双击程序名,在Arguments下点击加号,输入启动参数。
本站采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。
转载请注明:转载自 Elf Sundae's Blog(http://www.cnblogs.com/elfsundae) (小糊涂闲)
转载请注明:转载自 Elf Sundae's Blog(http://www.cnblogs.com/elfsundae) (小糊涂闲)