Friday, September 25, 2009

Assignment #1 Problem

I was going over the io_displayflag function stuff located here and I noticed a problem. First of all, it didn't specify which value we were supposed to return after it's done. Secondly, and this is more confusing, is that we cannot alter the contents of the format char. array, since it was designated as being const. This conflicts with the requirement that we're supposed to replace format[1] with either a space (' ') or a check (I'm using 'X' here), since const stuff can't be modified. I'm stumped here and I can't think of what to do. Maybe the arguements should be changed. If anyone has any thoughts on the matter, I'll all ears.

Wednesday, September 23, 2009

Helpful Reading

I was looking for helpful resources for C programming and I found it with the book labeled simply "The C Programming Language" by Brian Kernighan and Deenis M. Ritchie. It contains alot of the commands that C has and some helpful examples as well. It's not very pretty to look at but it does its job well enough.

Thursday, September 17, 2009

Challenge #1

I was looking over some of the code for the first challenge under the To do List and I was inspired to do my own version of the code. Mine looks like:


void GetInt(char *strint, int val){
char string[80];
int num=0; int num2=0;

/* THis will convert each digit to a char, then cuts off a digit due to
narrowing involved with dividing an integer. Comes out in reverse order */
while( val >0){
string[num++]= (val%10) + '0';
val/=10;
}

/*reverses the order, so the string will be in the right order.*/
for(num-=1;num>=0;num--){
strint[num2++]=string[num];
}
strint[num2]='\0';

}/*GetInt */

I've tested it and it works perfectly. True, it's not the most memory efficient solution (there's 80 elements in the local char array 'string') but I wasn't sure if malloc, calloc or realloc were allowed to be used for this challenge. Then again, I might of saved myself some headache by avoiding them.

Tuesday, September 8, 2009

My first blog.

Hello anybody reading this. This is my first post on this blog. Sorry that I couldn't think of anything interesting to say. This is for academic purposes.