L
lekaihuai
Unregistered / Unconfirmed
GUEST, unregistred user!
写了一个提取数字的程序,有点错误,能帮我看一下吗?
#include<stdio.h>
#include<stdlib.h>
#define LEN 256
char getline(char *s,int len)
{
int c;
char *p=s;
while(--len>0&&(c=getchar())!='/n')
*s++=c;
*s='/0';
return(s-p);
}
main()
{
char line[LEN],b[20],*ptrl,*ptrb;
int n=0,j,a[50];
getline(line,LEN);
ptrl=line;
while(*ptrl!='/0')
{
ptrb=b;
for(j=0;*ptrl>='0'&&*ptrl<='9';ptrl++,ptrb++,j++)*ptrl=*ptrb;
if(j){
*ptrb='/0';
*(a+n)=atoi(b);
n++;
}
if(*ptrl!='/0')ptrl++;
}
for(j=0;j<n;j++)printf("%d/n",*(a+j));
}
#include<stdio.h>
#include<stdlib.h>
#define LEN 256
char getline(char *s,int len)
{
int c;
char *p=s;
while(--len>0&&(c=getchar())!='/n')
*s++=c;
*s='/0';
return(s-p);
}
main()
{
char line[LEN],b[20],*ptrl,*ptrb;
int n=0,j,a[50];
getline(line,LEN);
ptrl=line;
while(*ptrl!='/0')
{
ptrb=b;
for(j=0;*ptrl>='0'&&*ptrl<='9';ptrl++,ptrb++,j++)*ptrl=*ptrb;
if(j){
*ptrb='/0';
*(a+n)=atoi(b);
n++;
}
if(*ptrl!='/0')ptrl++;
}
for(j=0;j<n;j++)printf("%d/n",*(a+j));
}