Is there a way to cast a the contents of a char* buffer into an int?

char buf[100];
int i;

strcpy(buf, "foo");

i = atoi(buf);

that?

WOW!! atoi, i totally spaced on that. Thanks alot (im not being sarcastice, i just feel like a moron) Thanks.