ch19_3.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //**********************
- //** ch19_3.cpp **
- //**********************
- #include<iostream.h>
- #include<strstrea.h>
- char* parseString(char* pString)
- {
- istrstream inp(pString,0); //ios::in方式,读到Null结束
- int aNumber;
- float balance;
- inp >>aNumber >>balance; //从串流中读入一个整数和浮点数 char* pBuffer =new char[128];
- ostrstream outp(pBuffer,128); //ios::out方式,字串长度128
- outp <<"a Number = " <<aNumber //写入pBuffer中 <<", balance = " <<balance;
- return pBuffer;
- }
- void main()
- {
- char* str ="1234 100.35";
- char* pBuf =parseString(str);
- cout <<pBuf <<endl;
- delete[]pBuf;
- }