[ create a new paste ] login | about

Link: http://codepad.org/T4bO1QeU    [ raw code | output | fork ]

jimmy0301 - C, pasted on Nov 17:
#include <stdio.h>                                                              
#include <stdlib.h>

#define NULL_ARGUMENT -1
#define Base 10

int myAtoi(const char *pcStr){

   int nSign = 1;
   int nRes = 0;

   if(pcStr == NULL)
      return NULL_ARGUMENT;

   for(; isspace(*pcStr); pcStr++);

   if(*pcStr == '-'){
      nSign = -1; 
      pcStr++;
   }   
   if(*pcStr == '+'){
      nSign = 1;
      pcStr++;
   }
   for(; isdigit(*pcStr); pcStr++){
         nRes = nRes * Base + ((*pcStr) - '0');
   }
   
   return (nSign * nRes);
}


Output:
1
2
In function `_start':
undefined reference to `main'


Create a new paste based on this one


Comments: