C is hard to wrap your brain around, if you're used to other types of programming.
In assembly, unless you add in pre-built libraries, something like an overloaded operator, [i.e. something that can accept 8 bit unsigned integers, AS WELL as signed 8 bit integers, and even accepts 16 bit values - sketchy example..], has to be implemented, as different separate assembly routines, and you branch off, depending on what your inputs are, and what your outputs are.
They used to call C, a macro language for assembly.
You'd write C language code, and it would spit out a whole bunch of stuff, that was C in the IDE, but assembly, when it's all said and done.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello World");
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/* Hello World program */
tags - their characters reverse, when going from an open comment tag, to a close comment tag
#include<stdio.h>
You tell the compiler, the # , that you want to INCLUDE, the console [text window interface program, no graphics or gui] support functions, so you can send messages out to the opened text window
main()
{
printf("Hello World");
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
and another flavor, C# (C sharp.. *.cs type files), will be good to see the alternative
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// A Hello World! program in C#.
using System;
namespace HelloWorld
{
class Hello
{
static void Main()
{
Console.WriteLine("Hello World!");
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// A Hello World! program in C#.
Using C#, you just put two forward slashes, and till the end of the line, is a comment
using System;
same idea as the include statement, just written differently
namespace HelloWorld
Tells the compiler to treat the following code, as a particular, something..
I'd need help explaining this one better.
{
class Hello
again, need a helping hand explaining classes
{
static void Main()
static means, the variables inside don't disappear, they exist, so they can be used again
void, means, you can send the routine values, if you wanted, but it won't spit any back at you.
If you had
static int Main()
the program would be obligated, to RETURN a value. The difference between a SUB and a FUNCTION, in QBasic, or a Method, and a <blank> in C variants.
{
Console.WriteLine("Hello World!");
Console, dot, WriteLine, there is something called console, with an action called writeline, and the dot separates the thing, from the actions it is capable of doing.
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cut here - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
C language is CAPS LOCK sensitive!!!
If you write something, ..
PURPLE
and then
purple
THOSE ARE TWO DIFFERENT VARIABLES, or names of whatever.
Also,
computerMonitorTest
This is called, camel notation, the first word is lower cased, and the ones after, all have capital letters.
Learned this, from someone teaching me C# for XNA Xbox Live development.
~Paul
[I don't want stupid whiney comments that I did this poorly, or weakly, I TRIED DANG IT. Deal with it.]
[also, I removed the CODE tags, cause it messed up my color tags]
P.S.
I have a PDF of C language, from old 70's computer magazines, goes into some detail about, the bare bones of C.
I need to look through my nOOk, and see what issue of the scanned magazine is, so I can properly link to the PDF that's online already.