Have macbook... What compiler can I get?

+1 Cate Peterson · July 15, 2014
I have a macbook and want to run the C code I learned from Bucky's videos .

I downloaded Sublime Text. It says I have 2 errors. (Itâ??s also not free and wants me to pay $70.) IT says this: "clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated.â??, which likely means I have wrong compiler, right?

What complier can / should I get? And how, would be helpful. Or how do I use on a mac?

Post a Reply

Replies

Oldest  Newest  Rating
+2 Mathias Frits Rørvik · July 15, 2014
No you have the right compiler (clang) which is C, C++ and Objective-C compiler.

The conio.h header file is windows specific. It is not a part of standard C. Also I don't recommend learning C from Bucky's old (seriously old videos).

Instead you can learn a great deal from Harvard's free CS50 course.
0 Cate Peterson · July 15, 2014
I just want the thing to run once...then I plan to move onto a new language. I thought the 15 bite size tutorials would be quick way to do it in a a couple days... not sure I want to invest time to do Harvard's CS50 course. 

I used Sublime Text 2.0 this time (instead of the 3 version). This time it said:
clang: error: no input files
[Finished in 0.1s with exit code 1]

I even took out the #include <conio.h>; line. I guess I just don't know how to work the compiler program. I think the code is correct.</conio.h>

Anyone use Sublime Text 2.0 on a macbook?
+1 Mathias Frits Rørvik · July 15, 2014
Programming is a pretty time-consuming investment, why are you doing this if you ain't got time for nothing? You are not going to be able to learn C from Bucky's videos, end of story. It misses plenty of important stuff, like pointers. CS50 can be followed at own pace. Lectures are available on YouTube. 


...Anyway back to your broken code.

Firstly conio.h is a legacy windows thing. Away with it.

Your comments are broken: 
WRONG: \* comment *\
RIGHT: /* comment */


your scanf's is also broken. You put a \n outside of the quotes, besides you don't need a \n in the scanf.

You left out a semicolon when assigning a value to the profit variable.

Your curly braces are messed up in the do while switch thingy.
the case's are broken. this is not how to use a switch statement, look it up. For this situation you'd be better of with a if else, else if.
The printf's are broken. You can't put your variables in the middle of the strings. You also again put \n outside the string.

You forgot parentheses around your while.


Also getch is in conio. Use getchar(). 

Oh yeah lastly, even you get all these things fixed you won't get the right result since you are using floating point numbers with integers
+1 Cate Peterson · July 16, 2014
Mathias: Thank you for the debug help. I did change to if and else if, but I will try learn switch later. I just never got the code compiled at all until I learned the below. Hope it can help other mac users. I still have to practice with the \n placement. My program ran and I was able to debug (with your generous guidance) once I answered the question I posed. I guess my whole problem was with the compiler and terminal process on a mac, which seems less intuitive than on a PC and doesn't have that separate execute/run screen like shown on videos! 
THE ANSWER WAS:

To Compile:
Click on the magnifying glass symbol in upper right corner of screen.
Type in terminal and click it.
In the terminal window that opens type gcc then type a space (this space maks a difference: no space-no run) 
Drag file (or enter location name) then type a space
Type -o then type a space
Type filename (you choose a file name of course)
Hit enter. (That compiles it, tells you lines to debug if needed.)
To Run:
In same window type ./filename (of course use the name of the file you choose above.


I want to learn "A" programming language well, but probably not C. I merely wanted to test waters before moving on. What language should I invest my time in?
+1 Mathias Frits Rørvik · July 16, 2014
It is even easier way would be to simply type

$ make <filename>
$ ./<filename>


Notice that you leave out .c

anyway, C can be a bit tedious as you need to deal with memory and pointers. 

If I were you I'd figure out what I actually want to achieve by learning programming. C is nowadays used for embedded stuff and systems programming. 

Do you want to make websites?
Do you want to make apps?
Games?
Manipulate data?
0 Cate Peterson · July 16, 2014
Do I still have to open terminal and type gcc and drag file?

All the videos just show clicking some sort of compile & run button and window for io opening by itself. 

Want a new career.
I've got about 4-6 more years of kids in school, then I want to do something different.
I am adaptable. What languages would be in demand for paying jobs in the future?
+1 Mathias Frits Rørvik · July 16, 2014
No, make runs clang for you. So navigate to the same directory as your .c file and type "make <filename>" without the .c

To your other question It is hard to say which languages will be relevant, but I found this nice list.

http://mashable.com/2014/01/21/learn-programming-languages/
0 Ashish Ahuja · July 19, 2014
In the videos, Dev C++ compiler has been used to compile and run the code while allows you that clicking a run button functionality. And as far as learning a language is concerned, it depends on what you are thinking to do. There are a lot of things you can get into like web development, software development, mobile phone apps development.

Web as well few mobile applications and software too these days are widely using languages including HTML, CSS, and Javascript.
As far as programming is concerned there are options like Java, C# for both desktop applications as well as mobile phones development etc.
Its better to research on few of the languages and then reach back for any more queries :)
-3 Ashish Ahuja · July 21, 2014
Dev C++'s compiler. It was a typo :angel:
0 Arend Peter Castelein · July 21, 2014
Like fructose and lama said. People you see in videos are using IDEs. IDEs are programs which include both the text editor and compiler. Compiling in terminal is different. Compiling in terminal should just be using a compile and run command. You've included opening terminal in your compiling steps but you really only need to open it once per development session and you can leave it open for the whole time.

As Mathias said it's easiest to be in the same directory as the file that you're compiling/running, this way you can refer to the file only by the filename instead of the full directory. When you'r dragging the file into terminal I believe that's copying over the full directory name.

Here's a video I found explaining how to navigate terminal.
https://www.youtube.com/watch?v=Vhcx4KJbtes

As for which programming language you should learn. In my opinion it doesn't matter much at least for starting out. Most programming languages share the same core scripting aspects (if statements, for loops, variable creation, etc.). You can learn the language then use projecteuler.net to practice you're logic skill. The process of learning your first language can give you a better idea of what area you want to specialize in, and the logic skills from your first language can be applied to any area you go in. 

I'd probably recommend starting with a language that's a little easier to learn to start with. C and C++ have pointers and memory allocation which makes them a little trickier. Java and C# are a little easier and Python, Visual Basic and Javascript are easier yet. 
  • 1

C

107,109 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator