Saturday, June 19, 2010

Bitwise Operator



This is what I learned about bitwise operators the other day (I set it up in a table so that I can remember what goes where)







































Operator
Syntax
Example
Bitwise Not ~a ~0111 = 1000
Bitwise OR a | b 0111 | 0000 = 0111
Bitwise And a & b 0111 & 1111 = 0111
Bitwise XOR a ^ b 0111 | 1111 = 1000
Bitwise Shift Left a << 2 0111 = 1100
Bitwise Shift Right a >> 2 0111 >> 2 = 0001
Bitwise Shift Right a >> 2 1000 >> 2 = 1110


*Right shift depends on sign and unsigned, unsigned always put preceding number(s) as 0, if it is signed, it depends on if the first number is 1 or 0, if it is 1 then the preceding number(s) become 1
*(I hope I copied it right)*

Wednesday, June 9, 2010

[HelloÍÍÍ] iof_displayMenuItem

Struggling once again... this time I am having funny characters with my output (of spaces) when I use iof_displayMenuItem


I used the iof_display to output the menu. If I use iof_putch(' '), it'll output a space but if I use it in a loop, "Ì" characters show instead of spaces...

I am using this as my tester for the iof_displayMenuItem

#include "iof.h"

int main()
{
char str[5] = "HELLO";
iof_init();
iof_clrscr();
iof_displayMenuItem("[]", str, 15, 1, 10, 1);
iof_getch();
iof_end();
return 0;
}

Monday, May 31, 2010

Linux Compile Fixed!

Okay scratch that out. Seems like trying it again and again seem to work!


In case anyone cares, here's the input code for Borland:

#define UP_KEY 1072
#define DOWN_KEY 1080
#define LEFT_KEY 1075
#define RIGHT_KEY 1077
#define PGUP_KEY 1073
#define PGDN_KEY 1081
#define ENTER_KEY 13
#define TAB_KEY 9
#define BACKSPACE_KEY 8
#define DEL_KEY 1083
#define HOME_KEY 1071
#define END_KEY 1079
#define ESCAPE_KEY
#define INSERT_KEY 1082
#define F1_KEY 1059
#define F2_KEY 1060
#define F3_KEY 1061
#define F4_KEY 1062
#define F5_KEY 1063
#define F6_KEY 1064
#define F7_KEY 1065
#define F8_KEY 1066
#define F9_KEY 1067
#define F10_KEY 1068
#define F11_KEY 1133
#define F12_KEY 1134


Here is for Linux and (I assume it will work for) MAC

#define UP_KEY 259
#define DOWN_KEY 258
#define LEFT_KEY 260
#define RIGHT_KEY 261
#define PGUP_KEY 339
#define PGDN_KEY 338
#define ENTER_KEY 10
#define TAB_KEY 9
#define BACKSPACE_KEY 263
#define DEL_KEY 330
#define HOME_KEY 362
#define END_KEY 385
#define ESCAPE_KEY 27
#define INSERT_KEY 331
#define F1_KEY 265
#define F2_KEY 266
#define F3_KEY 267
#define F4_KEY 268
#define F5_KEY 269
#define F6_KEY 270
#define F7_KEY 271
#define F8_KEY 272
#define F9_KEY 273
#define F10_KEY 274
#define F11_KEY 275
#define F12_KEY 276

CHEERS!

Linux Compile Errors!

So I had an hour of spare time to work on something... knowing I have copying issues, I decided I would use this time to compile the 1st part of the assignment. To my surprise my borland compilation was successful (after some time of configuring the compiler)




So I thought I was lucky and decided to compile with the Linux (through the matrix server) and well, it didn't go as well. I ended up with some funny error of "undefined reference to "... I don't know what I did wrong so I decided to google it. Through googling, I found that it can not find the library to the . Funny enough I forgot which library I am suppose to use... or . I decided to try both but failed and ended up with the same problem.

My problem now is how do I get the library for the linux?




(I hate you error)

Wednesday, May 26, 2010

Address

Once again Fardad made me feel like I know nothing about C...
He explained what an address is. Address is nothing but an integer (I hope i got that right)... an unsigned integer.

Anther cool thing I learned today in class (and possible to get me fired from a job in coding) is that we can code arrays like this:



int a[2] = {2,4,5}
a[0]

can be rewritten as

int* b = a
b*2


On the side note, today in class, Fardad gave us a question to be answered. Using the same rules (can not use an if statement or the ? operator) add 1 line to the for loop to print out any number in the array greater than 3. I think I solved it but never tried it... I'm not sure if I should post the plausible answer or not...

Wednesday, May 19, 2010

Conditional Compilation

Today in class, I learned what the true value of the "#" is used for. It is used before compilation begins. That means anything with the # sign will be done first before the "actual" program starts to compile and run. This helps a lot with the different compilation we need to do later.

For example:

#define DoIt

Int main() {
#ifdef DoIt
Double a = 1.12
Double b = 2.12
#endif


if #define DoIt doesn't exist then the Double a = 1.12 and Double b = 2.12 would not compile (it'll be skipped during compilation)

Wednesday, May 12, 2010

Hello World

This is my first time blogging so I thought it is a neat way of using the Hello World.

HELLO WORLD.

*Doesn't seem very fun*
*Apparently this took me 10 minutes to write*