Home Download Buy Blog Forum Support

How to run the program

How to run the program

Postby MrCube on Fri Dec 13, 2013 3:21 pm

Hi,
I am new to coding. I am using Mac OSX Mountaion Lion. To start off I have decided to use Sublime text 2. It is great with a beautiful interface. However, I am having a little problem. I wrote a simple program using C language. How do i run the program and see how it works?

I am using Sublime Text 2.


Thanks
MrCube
 
Posts: 3
Joined: Fri Dec 13, 2013 3:19 pm

Re: How to run the program

Postby adzenith on Sun Dec 15, 2013 9:00 pm

Did you try Tools>Build?
adzenith
 
Posts: 1213
Joined: Mon Oct 19, 2009 9:12 pm

Re: How to run the program

Postby MrCube on Tue Dec 17, 2013 6:08 am

I wrote this code,
Code: Select all
#include <stdio.h>

int main()
{
  printf("Hello world\n");
  return 0;
}


I went to Tools -> Built. Then came this message.
Code: Select all
"/Users/mohamedsuhail/Desktop/program.c:1:19: error: stdio.h: No such file or directory
/Users/mohamedsuhail/Desktop/program.c: In function 'int main()':
/Users/mohamedsuhail/Desktop/program.c:5: error: 'printf' was not declared in this scope
[Finished in 0.0s with exit code 1]"
MrCube
 
Posts: 3
Joined: Fri Dec 13, 2013 3:19 pm

Re: How to run the program

Postby MrCube on Tue Dec 17, 2013 3:38 pm

Someone please help so i can continue using Sublime Text 2 for C. I don't want to use another program. :|
MrCube
 
Posts: 3
Joined: Fri Dec 13, 2013 3:19 pm

Re: How to run the program

Postby jbrooksuk on Tue Dec 17, 2013 3:48 pm

This isn't a problem with Sublime Text, it's your development setup that's incomplete.

For OSX, you need XCode installed, then run
Code: Select all
xcode-select --install
to install everything needed.
jbrooksuk
 
Posts: 754
Joined: Sun Apr 11, 2010 10:37 am
Location: England

Re: How to run the program

Postby Vortico on Sat Dec 21, 2013 5:43 am

You could use Sublime Text's build system, but I wouldn't recommend it until you learn your way around the command line. To build, cd into your source directory and use
Code: Select all
cc -o program program.c
Vortico
 
Posts: 8
Joined: Fri Jul 13, 2012 1:12 am


Return to General Discussion

Who is online

Users browsing this forum: Jim, pete340, RyanJ and 40 guests