Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c

Status
Not open for further replies.
Are you asking how to use it???
If so, the "man" page...

NAME
atoi - convert a string to an integer.

SYNOPSIS
#include <stdlib.h>

int atoi(const char *nptr);

DESCRIPTION
The atoi() function converts the initial portion of the
string pointed to by nptr to int. The behaviour is the
same as

strtol(nptr, (char **)NULL, 10);

except that atoi() does not detect errors.

RETURN VALUE
The converted value.

...if you are asking how it works internally, you can look at...

...or the GNU source...
int atoi(const char *number)
{
register int n = 0, neg = 0;

while (*number <= ' ' && *number > 0)
++number;
if (*number == '-')
{
neg = 1;
++number;
}
else if (*number == '+')
++number;
while (*number>='0' && *number<='9')
n = (n * 10) + ((*number++) - '0');
return (neg ? -n : n);
}
 
i have doubt in C language of header file time.h

in that we have clock() function it reterns processor clock speed,

i need to find the total time to execute the function

then how can i find it?
 
A very common tool used for finding out
how much time a program spends in a funtion
are &quot;prof&quot; and &quot;gprof&quot;. This URL will give you a wealth of information
on various tools including &quot;prof&quot;...

You should also look at the man pages for prof and gprof.
Essentially, you compile like...

cc -o prog -p prog.c <-- to use prof
cc -o prog -pg prog.c <-- to use gprof

...then you run the program...

prog

...then you display the profile...

prof prog

...or...

gprof prog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top