Anope IRC Services
Anope Development => Modules => Topic started by: Blue_Key on May 27, 2006, 05:03:12 PM
-
How i can pass char* to int ?
i make this but services crash...
char *argv[5];
int max_join_time = 3;
... code ...
if ((argv[1] != NULL) && (isdigit(argv[1]))) {
max_join_time = atoi(argv[1]);
}
-
Write function:
#include<stdlib.h>
int StringToInt(char *str)
{
char c;
int i,digit=0;
int k=1;
for(i=strlen(str);i>0;i--)
{
digit+=(str-'0')*k;
k*=10;
};
return digit;
}
This function convert String to unsigned Integer. WARNING this function not check input argument
-
There is a C function (on POSIX-systems, which anope is designed for) which converts strings to integers: http://www.die.net/doc/linux/man/man3/strtol.3.html
-
nice it's good, thank :)