Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Objective-C Basics (Retired) Introduction to Objective-C Syntax Overview

Difference between main.m and main.c?

Quick question. I tried to replicate the files on my own in xcode as opposed to just downloading them. When I ran my program, I got several errors. Comparing to Doug's code, I noticed that he had a main.m file vs. my main.c file. When I changed to main.m, my program ran perfectly. What's the difference between main.m and main.c? How do I know which one to use?

2 Answers

Stone Preston
Stone Preston
42,016 Points

I believe main.c is used for c programs, whereas main.m is used for objective c programs. If you download the project templates file listed in the teacher notes of the video (here is a link to the download) you will see there is a myFirstObjectiveCProgram folder and a myFirstCProgram folder. The objective c xcode project (the one you need to be using) includes a main.m whereas the myFirstCProgram xcode project contains a main.c file