Content

Post new topic Reply to topic

[C & Quake] Programming Primer

Author Message
Maszek View user's profile Send private message

Reply with quote Wednesday, August 01, 2012

As the title suggests, me and Zaynon have "interrogated" Zeth for about a hour, throwing questions related to basic programming things at him. He answered to the best of his knowledge. This is not meant to be a full-fledged tutorial, merely a Frequently Asked Questions of sorts.

C Data types:
-------------------------------------

Float
Floats are decimals. 3.89 would be a float.
Floats can have zeros in the decimal spots to essentially make them whole. Explanation about the different types of floats:

Decimal forms have two types: floats and doubles. A float can have 7 digits and is normally 32-bit by default. A double would be 15-16 digits and consume 64-bits. A float could be 418273.1 or 4.128731.

Integer
Integers are whole numbers. 389 would be an integer. Explanation about the different types of integers:

There are byte, short, and long integers, and each of these can be signed or unsigned.

This defines their range in numbers and how many bits they consume.

The range of a byte integer is 256. If it is signed, it will be from -128 to 127. If it is not, it will be from 0 to 255.

The range of a short integer is from -32768 to 32767. Sounds familiar? By default, integers are signed and short unless declared otherwise.

Long integers have a range of −2,147,483,648 to 2,147,483,647 if signed. An unsigned long integer would essentially have a range of 4.2 billion.

Character
They are what they sound like: A single, one byte large ascii character. While characters are not useful on their own most of the time, they can be used to form strings if stored in an...

Array
An array, in C, is basically just a collection/list of a certain data type. It is of a fixed size.

For example: int numbers[3] would be an array of 3 integers.An important fact to remember is that while setting them, you start from 0. for example: numbers[0] = 81 would set the FIRST integer's value to 0.

An array of characters is used to create a string.

For example, character name[32] will create an array with the size of 32. Never exceed the size! You can create an array without specifying the size if you specify the content. For example : character name[] = Zaynon will make it's size 6.

All right, that's it. I do not think I have left anything out.

Zeth The Admin View user's profile Send private message

Reply with quote Wednesday, August 01, 2012

I would organize this information to a more readable and straightforward form rather than textual log form. This will help streamline its visibility and not require an external URL to view.

Maszek View user's profile Send private message

Reply with quote Thursday, August 02, 2012

Zeth wrote : I would organize this information to a more readable and straightforward form rather than textual log form. This will help streamline its visibility and not require an external URL to view.

Done.

Wolverine View user's profile Send private message

Reply with quote Friday, August 03, 2012

Nice thread.

What about Double and Structures??

Zeth The Admin View user's profile Send private message

Reply with quote Friday, August 03, 2012

Structures, functions, bools, bitflags, enumerations, pointers, references, mathematical operations, loops, conditions, scope, headers, includes, and a number of specific Quake 3 things. I think this guide will eventually get there if it can keep terse.

Post new topic Reply to topic

Actions

Online [ 0 / 6125]