Skip to content

Commit

Permalink
Update c面试.c
Browse files Browse the repository at this point in the history
  • Loading branch information
errorcode7 committed Dec 5, 2013
1 parent c539572 commit c6c931a
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions c面试.c
Expand Up @@ -3,14 +3,40 @@
#include<string.h>
int main()
{
char *p= "abcdefg";
char *p= "12345";
int len;
len=strlen(p);
while(len>=0)
while(len>0)
{
printf("%c",*(p+len));
printf("%c",*(p+len-1));
len--;
}
printf("\n");
return 0;
}
//String To Int
int strtoint(char *str)
{

int n=0;
int neg=0;
if(*str=='-')//is negative number?
{
str=str+1;
neg=1;
}
while(*str!=0)//12345
{
if('9'<*str||*str<'0')
{
printf("string error!\n");
exit(-1);
}
n=n*10+*str-'0';
str++;
}
if(neg)
return -n;
else
return n;
}

0 comments on commit c6c931a

Please sign in to comment.