C tutorials for a beginner
does anyone know of *GOOD* beginner tutorials for C? post them, please.
Try this one:
http://www.eskimo.com/~scs/cclass/notes/top.html
or, if you want something simpler & less detailed:
http://www.cocoadevcentral.com/articles/000081.php
http://www.eskimo.com/~scs/cclass/notes/top.html
or, if you want something simpler & less detailed:
http://www.cocoadevcentral.com/articles/000081.php
thanks. i have a question. is there a link between cocoa and c?
Tyaedalis Wrote:thanks. i have a question. is there a link between cocoa and c?
The language of choice for Cocoa programming is objective-C. Objective-C is a true superset of C. That means that objective-C is C with stuff added to it. If you want to start writing plain C code in the middle of an objective-C method, you can do so.
am having trouble with the
i dont know what the stdio.h means
i kow it means standard something, but what does it do?
does the program need it?
also, how do i set up Xcode for C compiling?
Code:
#include <stdio.h>i dont know what the stdio.h means
i kow it means standard something, but what does it do?
does the program need it?
also, how do i set up Xcode for C compiling?
BTW, have you ever programmed before (in any language)?
If you haven't, you should consider learning Python. It's simple and makes a great first language. Here's a great (free) book to learn from: How to Think Like a Computer Scientist: Learning with Python (PDF)
If you haven't, you should consider learning Python. It's simple and makes a great first language. Here's a great (free) book to learn from: How to Think Like a Computer Scientist: Learning with Python (PDF)
i have learned the basics of BASIC
but i cant remember anything from it. i tried learning C before recntly, but got distracted... pythons seems boring. what can you do with it and how do you compile (or interperet) it?
but i cant remember anything from it. i tried learning C before recntly, but got distracted... pythons seems boring. what can you do with it and how do you compile (or interperet) it?
Tyaedalis Wrote:am having trouble with the
Code:
#include <stdio.h>
i dont know what the stdio.h means
i kow it means standard something, but what does it do?
does the program need it?
also, how do i set up Xcode for C compiling?
#include someFile means "paste the contents of someFile here". You'll find stdio.h in /usr/includes/stdio.h. It defines a bunch of stuff (like the printf function) which allows your program to get input an produce output (hence, the io part).
You don't need Xcode for plain C (although it helps once you start making more complex programs). Use GCC for now. Here's how:
1) open Terminal
2) cd to the directory of your source code (if you don't know how to use a command line, google for "basic unix tutorial")
3) type gcc myFile.c -o whateverYouWantToCallYourProgram
4) run it by typing ./nameOfYourProgram
Tyaedalis Wrote:pythons seems boring. what can you do with it and how do you compile (or interperet) it?
Ever heard of BitTorrent? That was written in Python.
To run a Python program, just type python nameOfMyPythonProgram.py
There's no need to compile your code before running it.
type that in the terminal?
and i write the code in textedit?
and i write the code in textedit?
Tyaedalis Wrote:type that in the terminal?
and i write the code in textedit?
Yes. Although, you can write the source code in any text editor you like (including Xcode). If you want to write it in TextEdit, make sure you save it as plain text (not RTF).
ok, i got the normal
done. it's exactly the same as BASIC.
i think i will just jump into C, caus ei started on c and i like it.
i wrote this a while back in C:
Code:
print "Hello, World!"done. it's exactly the same as BASIC.
i think i will just jump into C, caus ei started on c and i like it.
i wrote this a while back in C:
Code:
#include <stdio.h>
int main()
{
char name[20], age[9];
printf("\nWhat is your name? ");
scanf("%s", name);
printf("How old are you? ");
scanf("%s", age);
printf("Your name is %s, and you are %s years old.\n", name,age);
return 0;
}
Be careful. There is a SERIOUS buffer-overflow problem with that program. Try entering a really long name and age.
One solution is to limit the number of character that scanf will read:
scanf("%8s", name);
fflush(stdin);
Note that I used 8 instead 9. That's because a C string is an array of characters which end in the NUL character ('\0').
Python hides these kinds of details for you.
One solution is to limit the number of character that scanf will read:
scanf("%8s", name);
fflush(stdin);
Note that I used 8 instead 9. That's because a C string is an array of characters which end in the NUL character ('\0').
Python hides these kinds of details for you.
explain the
please
and in the scanf("%8s", name);
the 8 means only take 8 letters?
Code:
fflush(stdin);and in the scanf("%8s", name);
the 8 means only take 8 letters?
yes, "%8s" means read up to 8 characters.
fflush(stdin) means empty the standard input buffer so that the next time I call scanf(), there won't be junk in the buffer.
fflush(stdin) means empty the standard input buffer so that the next time I call scanf(), there won't be junk in the buffer.

