This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / C++ out 问题,紧急求救?我不是C++ PROGRAMMER 但是要该一个C++BUG.
out2<< (counter - 59) << "--" << counter << "\t";
结果如下:
1--60
61--120
121--180
181--240
241--300
如何该才能得到如下结果
001--060
061--120
121--180
181--240
241--300
谢谢您的帮忙
-waiting(OK);
2003-2-7
{243}
(#1026550@0)
-
try this#incldue <iomanip>
using namespace std;
out2<< setw(3) << setfille('0') << (counter - 59) << "--" << setw(3) << setfill('0') <<counter << "\t";
-oasis(oasis);
2003-2-7
{156}
(#1026646@0)
-
?setfille(0) << setw(3) ?
-farmer(农夫®);
2003-2-7
{24}
(#1026663@0)
-
http://www.cplusplus.com/ref/iostream/ostream/operatorltlt.html
-abracadabra(Just do it);
2003-2-7
(#1026715@0)
-
Thanks all for the quick response, but is seems I didn't get the answer,
couyld u please make it more clear.
-waiting(OK);
2003-2-7
(#1026834@0)
-
// setw example
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
cout << setw (10);
cout << 77 << endl;
return 0;
}
-abracadabra(Just do it);
2003-2-7
(#1026877@0)
-
my code like this:
#include <fstream.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
......
ofstream out;
.......
why there is an error message "ambiguous symbol"
-waiting(OK);
2003-2-7
(#1026982@0)
-
注释ofstream out;
-abracadabra(Just do it);
2003-2-7
(#1026989@0)
-
Thanks, I need out to generate a file, that seems there is a conflict between fstream.h and iostream
-waiting(OK);
2003-2-7
(#1027005@0)
-
#include <fstream.h> to #include <fstream> i dont know if it work. but u'd better use the ANSI C++
-abracadabra(Just do it);
2003-2-7
(#1027011@0)
-
Thanks it doesn't work, it seems i need another way
-waiting(OK);
2003-2-7
(#1027018@0)
-
<iomanip> only for iostream
-abracadabra(Just do it);
2003-2-7
(#1027035@0)
-
so does this mean i can't use setw in this case
-waiting(OK);
2003-2-7
(#1027037@0)
-
ok now?
-abracadabra(Just do it);
2003-2-7
(#1027112@0)
-
set cout.width()
-abracadabra(Just do it);
2003-2-7
(#1027044@0)
-
cout.fill('0');
cout.width(3);
cout <<(counter - 59);
cout.width(2);
cout << "--";
cout.width(3);
cout << counter << endl;
-abracadabra(Just do it);
2003-2-7
(#1027056@0)
-
Thanks so much for your kindly help
-waiting(OK);
2003-2-7
(#1027249@0)
-
one more question, I hope I didn;t bother you to much?i can use GetCurrentTime() to get a time object, how can I generate another time object which is 20 seconds later.
Thanks so much
-waiting(OK);
2003-2-7
{132}
(#1027276@0)