Dear Andreychuk and/or ubuntu developers:
thanks your reply and concern,
it solved
it caused by
my a.out is actually Example 7-7, but I thought it is 7-8, so I enter
7-8's input(suggested by book)
then it cause (bad result), /* but why,
in 7-7, the main line is
vectorstring::iterator p =
partition(v.begin(), v.end(),
bind2nd(lessstring(), foo));
why the input of 7-8 feed in to 7-7 (above) will
cause Segmentation fault?
is another interesting assignment
*/
now I have another question also on this same book,
on its Example 11-11. Generating random numbers using rand
I follow/copy that book's code
it can compile and run
but
I am curious since it is random number and it seed by clock()
srand(static_castunsigned int(clock()));
why it always output same result?
then someone in linuxquestions.org told me, clock() is used as cpu
speed , so it is always same
he suggest I should change it as time()
but then I got compile erros as following
g++ 4.5.2-
eric@eric-laptop:~/cppcookbook/ch11$ g++ Example11-11.cpp
Example11-11.cpp: In function ‘int main()’:
Example11-11.cpp:14:41: error: too few arguments to function ‘time_t
time(time_t*)’
/usr/include/time.h:186:15: note: declared here
I am hard to find any useful resource about how to use time() as
seed to generate random number in web. /* or maybe I not industry
enough */ plz help
Eric
On Thu, 2011-07-21 at 22:49 +0400, Dmitry Andreychuk wrote:
On Tue, 2011-07-12 at 22:48 -0700, eric wrote:
Dear advanced c/g++ programers:
A program request me to enter twice input
that program probably is tested good on visual c++ 7.1 on window xp,
but my system is g++ on linux(Ubuntu10.04)
It assume
Enter some strings: a b c d
^Z
Enter some more strings: d e f g
^Z
Union: a b c d e f g
Difference: a b c
Intersection: d
all these you can get from page 273 and 274 of book(c++ cookbook)
but my test result is
---
eric@eric-laptop:~/cppcookbook/ch7$ ./a.out
Enter a series of strings: a b c d
^Z
[7]+ Stopped ./a.out
eric@eric-laptop:~/cppcookbook/ch7$ ./a.out
Enter a series of strings: a b c d
{a, b, c, d}
Segmentation fault
---
second case , I used EnterControl-D
first case, I used EnterControl-Z
Sorry for a late answer.
I've just run it and had no segfault (using EnterControl-D).
Ubuntu 11.04; g++ 4.5.2-1ubuntu3
Try debugging it with gdb.
--
Dmitry Andreychuk
--
Ubuntu-devel-discuss mailing list
Ubuntu-devel-discuss@lists.ubuntu.com
Modify settings or unsubscribe at:
https://lists.ubuntu.com/mailman/listinfo/ubuntu-devel-discuss