查看: 850|回复: 2
|
有关C++的问题。。。
[复制链接]
|
|
请问如何用 C++ hidden characters 呢?
例如:
cout 的 value 是 137.5,
但我只要display '5',
我不要display 137.。
有甚么办法吗?
[ 本帖最后由 回归者 于 22-8-2006 02:30 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 22-8-2006 10:44 PM
|
显示全部楼层
答案:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
double number = 137.5;
char myword[10];
string test;
//convert double to string
gcvt(number,4,myword);
//Scans string1 character by character, returning a pointer to the first character
//that matches with any of the characters in string2
test = strpbrk(myword,"5");
cout<<test;
system("Pause");
return 0 ;
} |
|
|
|
|
|
|
|
发表于 24-8-2006 06:56 PM
|
显示全部楼层
不能哦....
会有这个error....
c:\documents and settings\david\desktop\testing program\double convert string.cpp(16) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::al |
|
|
|
|
|
|
| |
本周最热论坛帖子
|