Code Bye

mac系统,如何编译运行.m文件

 

大家好啊,小弟刚开始学objective-c, 
很是郁闷, 在mac终端,什么命令可以编译运行.m文件呢,
比如,我现在有个123.m

#import <Foundation/Foundation.h>

int main(int argc, const char *argv[])
{
	NSLog (@"hello, LI Jialin!");
	return (0);
}

都看看书吧,.m文件是方法文件吧
20分
gcc hello.m -o hello -ObjC -framework Foundation
引用 2 楼 nongmin 的回复:

gcc hello.m -o hello -ObjC -framework Foundation

终于会了,多谢,还请问,我这个小段代码那里错了呢

#import <Foundation/Foundation.h>

int main()
{
	char *word[5];

	FILE *fin = fopen("/123.txt","r");

	char temp[100]; 
	int counter =0;
	while (fgets(temp, 100, fin))
	{
		temp[strlen(temp-1)]=""\0"";
		word[counter] = temp;
		counter++;
	}

	for (int i=0;i<5;i++)
	{
		NSLog(@"%s""s length is %d",word[i],strlen(word[i]));
	}
	return (0);
}


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明mac系统,如何编译运行.m文件