A project for CPROG by Andrew Brundage during the Fall 2011.
State the purpose of this project. What is the point of this project? What do we hope to accomplish by undertaking it?
To find out how much space each data type typically takes up of the ones specified below.
In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:
State the idea or purpose of the project. What are you attempting to pursue?
Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK.
Providing any links to original source material, such as from a project page, is a good idea.
You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.)
This project will be exploring the nature of some of the data types available to us in the C Programming Language. How much space is allocated to each type, how many numbers can exist within each type, and what are the ranges available for each type?
A program will be written that will display (to STDOUT) the size (in bytes), the lower and upper bounds of each studied type, and display the total quantity of values possible with each type.
The data types covered for this project will include:
The sizeof() and printf() functions, as well as arithmetic operators, will be utilized in performing much of the work.
#include <stdio.h> #include <stdlib.h> int main() { unsigned char unchar; signed char sichar; unsigned short int unshoint; signed short int sishoint; unsigned int unsint; signed int sigint; unsigned long int unlonint; signed long int silonint; unsigned long long int unllint; signed long long int sillint; printf("%3d bytes: unsigned char\n", sizeof(unchar)); printf("%3d bytes: signed char\n", sizeof(sichar)); printf("%3d bytes: unsigned short int\n", sizeof(unshoint)); printf("%3d bytes: signed short int\n", sizeof(sishoint)); printf("%3d bytes: unsigned int\n", sizeof(unsint)); printf("%3d bytes: signed int\n", sizeof(sigint)); printf("%3d bytes: unsigned long int\n", sizeof(unlonint)); printf("%3d bytes: signed long int\n", sizeof(silonint)); printf("%3d bytes: unsigned long long int\n", sizeof(unllint)); printf("%3d bytes: signed long long int\n", sizeof(sillint)); return 0; }
lab46:~/src/projects/datatypes$ ./datatypes 1 bytes: unsigned char 1 bytes: signed char 2 bytes: unsigned short int 2 bytes: signed short int 4 bytes: unsigned int 4 bytes: signed int 8 bytes: unsigned long int 8 bytes: signed long int 8 bytes: unsigned long long int 8 bytes: signed long long int lab46:~/src/projects/datatypes$
In performing this project, the following resources were referenced:
Generally, state where you got informative and useful information to help you accomplish this project when you originally worked on it (from Google, other wiki documents on the Lab46 wiki, etc.)