问题
填空题
试题源程序文件清单如下:
//proj2. cpp
#include<iostream>
using namespace std;
char*GetNum(char*src,char*buf)
while(*src!=’\0’)
if(isdigit(*src)) break;
src++;
if(*src==’\0’)
//********found********
(1) ;
while(*src!=’\0’&& isdigit(*src))
//********found********
(2) :
buf++:
src++:
*buf=’\0’:
return src:
int main()
char str[100], digits[20];
cin. getline( str,100);
char*p=str;
int i=1:
While((p=GetNum( p,digits))!=NULL)
cout<<"Digit string"<<i<<"is"<<digits<<endl;
//********found********
(3) ;
return 0:
答案
参考答案:* buf=* src
解析: 为了将字符串指针中的字符依次存储到buf中,应该采用指针运算符“*”,横线二处应该填写* buf=*src。