trying to implement this code in c
Hi,
I am trying to implement this PHP code in C:
Code:
function showCombinations($string, $traits, $i)
{
if ($i >= count($traits))
echo trim($string) . "\n";
else
{
foreach ($traits[$i] as $trait)
showCombinations("$string $trait", $traits, $i + 1);
}
}
$traits = array
(
array('Happy', 'Sad', 'Angry', 'Hopeful'),
array('Outgoing', 'Introverted'),
array('Tall', 'Short', 'Medium'),
array('Handsome', 'Plain', 'Ugly')
);
showCombinations('', $traits, 0);
Having a real hard time of it. I'm a PHP programmer, and the way C handles strings is so much different. Could anyone offer some help?