In pset4 I want to create randomly colored bricks. To that end I created a function that returns a hex string. When I run it I get a segfault. Using gdb I have narrowed down the issue to the below snippet:
string color = ""; int c = (int) (rand() % 256); sprintf(color, "%x", c);
The segfault is happening on the call to
How can I convert from an int to a hex string??