Haven’t been using C for awhile, I was struggling unnecessarily for my COMP9314 assignment. My main problem was with how to store a string with unknown length, or creating an array without specifying the size (GIVE ME JAVA’S VECTOR!!!).
At the moment, I did a dirty hack by creating an array of string with the size of 50. The reason why i need this kind of array is because I am reading the input from keyboard (xpath expression, for exampe: /first/second/third) and then split it into several strings ie (“first”,“second”,“third”). I suppose I can reiterate the string once to get the number of elements, then create an array with the size that I have discovered from the first iteration to hold the elements, this wouldn’t be a dirty hack, but boy, is it really necessary??
Anyway I might do this later as I think that’s the right thing to do eventhough I know that creating an array of 50 elements is fair enough assumption (don’t think they will test me with xpath expr with more than 50 elems, and memory wise, surely creating 40+ more space doesn’t really cost you alot in terms of memory)..
Yeah, if I were using Java, this assignment would be finished pretty soon.
22/08/04: Coding while my former BS group are having discussion outside.. sigh trinity is such a hard concept.. oh yeah, I found out few useful stuffs today!!! XML_SetCharacterDataHandler is actually not only handling text inside an XML tag but it also handles the spaces or tabs as well!! I now managed to print the result as the specs require only I haven’t done the attribute part, I think it should be straightforward.
Another annoying thing that has left me frustated today was the strncopy function, from references in the web, this function should be part of C standard library, but somehow it isn’t the case with my compiler (I did include and the other string functionalities work ok like strlen), fortunatelly I found a piece of code from the net that does similar thing.. Ah the power of re-using people’s code.
Hmm. I think nowadays programmers don’t have to code anything from the scratch and web developers don’t have to design sites from scratch either (given there are plenty of web templates out there that can easily be manipulated).
Ok enough blabbering, need to go back to coding.. yipie!! I love coding.