please visit the following link: http://www.techgig.com/codecontest/problem/Rolling-Dices-36

click on participate and please see the code editor on the right side. In the code skeleton there, you can see a function with taking two arguments,both character arrays.

I know a method to solve this problem if both the arrays were integer arrays.

But could anyone please help me with how to convert these char arrays into integer arrays.

the function signature cannot be modified.

If you don't wanna create an account in the site, here's the problem statement:

Two persons are playing a game of rolling 2 dices. Each person roll the two dices n times and record the outcomes( sum of value of two dices) of all the n attempts. So after n attempts of both the player we have two list corresponding to the n outcomes of two players. They want to know that whether they have got all possible outcomes( 2 to 12) same number of times or not. If they got all the possible outcomes same number of times then they are called lucky otherwise unlucky. So the question is that you have two list corresponding to the outcomes of two players you have to decide that whether the two players are lucky or not.

the code has to be written inside the function without changing the signature. I know a method to solve this problem if both the arrays were integer arrays.

But could anyone please help me with how to convert these char arrays into integer arrays.

void rolling_dice(char* input1,char* input2)
{
    //Write code here
}

Thanks in advance

Edited 3 Years Ago by Dani: Formatting fixed

But could anyone please help me with how to convert these char arrays into integer arrays.

No conversion is necessary, characers are nothing more than small one-byte integers with a range of values -127 to 126 or unsigned 0 to 255. You simply treat then as if they were int arrays.

This might help you:

#include <iostream>
using namespace std;

int main(){
        cout<<'a'+0; //prints out the ascii number of character 'a'
        return (0);
}

You're kidding, right?

Not quite

Standard way to do this is cout << (int)'a';

I didn't say it was the standard way, just said that it could help him...

Edited 4 Years Ago by Lucaci Andrew

This article has been dead for over six months. Start a new discussion instead.