C via Xcode Primer Tutorial

C via XCode Primer Tutorial

C via XCode Primer Tutorial

Here is a tutorial that introduces you to some aspects of C programming … example is a very rudimentary Student Results system …

  • use of struct
  • text file reading and writing
  • string manipulation

C is the grandparent of so many other languages, and it is interesting to think there was so much before C, and so much after. If you like Operating Systems you have to admire C. The kernel of Unix is C. As a result it is excellent at Operating System issues, but that doesn’t mean it knows the difference between the structure of a Mac OS X folder versus a Windows/DOS one. You still need to compile it in the environment that you are in.

There are loads of C compilers. Microsoft have been into C forevvvvvver from the Dos’sy old compilers through to the way you can still compile straight C code in Visual Studio C++ compilers for Windows/DOS. XCode for Mac OS X has C++ and will take straight C code. It is actually very interesting doing straight C in a C++ environment and seeing the bits that really were fundamental, versus those that are environmentally dependant. Functions like gets are no-nos in C++ environments, though it would have been a favourite approach back “in the old days”. So in the code you see here you see things like

fgets(buffer, 100, stdin);
if (strstr(buffer, “n”)) *(strstr(buffer, “n”)) = 0;

… has become a bit more awkward … rather than (“in the old days”) …

gets(buffer); // … or …
scanf(“%[^n]s”, buffer); // or scanf(“%s”, buffer);

In computing, C (/ˈsiː/, as in the letter C) is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.[4] Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. C program source code is free-format, using the semicolon as a statement terminator and curly braces for grouping blocks of statements. Its design provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system.[5]

C is one of the most widely used programming languages of all time,[6][7] and there are very few computer architectures for which a C compiler does not exist.

Let’s see some C using XCode for this …

Link to C information … from Wikipedia from which quote above comes.
Link to some downloadable programming code … rename to main.cpp (or main.c for straight C compiling) for use.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Tutorials, Xcode and tagged , , , , . Bookmark the permalink.

12 Responses to C via Xcode Primer Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *