// file: /data/courses/ece_1111/lectures/current/lecture_05/example.cc // // local include files // #include "example.h" // function: main // // This is a simple program that prints to the terminal. // int main(int argc, const char** argv) { // grab a value from the command line // long lval = atoi(argv[1]); // fprintf(stdout, "lval = %ld (%s)\n", lval, argv[1]); float fval = atof(argv[2]); // fprintf(stdout, "fval = %f (%s)\n", fval, argv[2]); // declare an unsigned char - one byte // unsigned char foo; for (long i = 0; i < 260; i++) { foo = i; // fprintf(stdout, "%d: %d\n", i, foo); } // declare a signed character - ASCII // char c; for (long i = -128; i < 128; i++) { c = i; // fprintf(stdout, "%d: %c (%d)\n", i, c, c); } // declare a 16-bit integer // short s; unsigned short us; for (long i = -32768; i < 32768; i++) { s = i; // fprintf(stdout, "%d: %d (%d)\n", i, s, s); } // declare an "int" integer // int k; unsigned int uk; //for (int i = -pow(2,31); i < pow(2,31); i++) { // k = i; // // fprintf(stdout, "%d: %d (%d)\n", k, k, k); // } // declare long integer // long l; unsigned long ul; // for (long i = -2^63; i < 2^63 - 1; i++) { // s = i; // fprintf(stdout, "%d: %d (%d)\n", i, s, s); // } // declare a floating-point number // float x = 27.00125; fprintf(stdout, "x = %f\n", x); // declare a double precision floating-point number // double y = 27.00125; fprintf(stdout, "y = %f\n", y); // declare a super long // long long really_long; // double double really_long_also; // declare a character string // // char* joe = (char*)"Joe"; // fprintf(stdout, "joe = %s\n", joe); // declare a boolean value // bool b = true; bool bb = false; // how do I get the number of bytes in a number? // long z; fprintf(stdout, "the size in bytes is %d\n", sizeof(z)); fprintf(stdout, "the size in bytes is %d\n", sizeof(long)); // exit gracefully // return(0); }