I should first start out by saying that I come from a Java background. That being said, I'm just starting to learn C and I really struggle with the use of pointers. The concepts are simple enough, but actually using them proves to be a rather difficult and frustrating experience for me.
At any rate, I'm trying to create a function that replicates atoi
without using the stdlib.h
library. I'm thinking it's a simple matter of casting, but when I test it I get some really strange results. What I have is as follows:
int myatoi(const char* str){
return (int)*str;
}
Given that I don't really know what I'm doing when it comes to pointers, I'm most certainly doing something wrong, but I have absolutely no idea what.