Error in function.

Cant get this code to work. Please help me anyone.


*************************
labb4.cpp(42) : error C2664: 'initialize' : cannot convert parameter 1 from 'char [53][32]' to 'char ** '
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

*************************
#include "stdafx.h"
#include "string.h"

int initialize(char**);

int initialize(char* deck[53])
{

char card_types[4][8] = {"hjarter", "ruter", "spader", "klover"};
char card_values[14][6] = {"ess", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "knekt", "dam", "kung"};

int i, j, k = 0;

for (i = 0; i < 4; i++)
{
for (j = 0; j < 14; j++, k++)
{

strcpy ( deck[k], card_types[i] );
strcat ( deck[k], " " );

strcpy ( deck[k], deck[k] );
strcat ( deck[k], card_values[j] );

//printf ( "%s
", deck[k] );
}
}


return 0;
}


int main(int argc, char* argv[])
{

char deck[53][32];

initialize( deck );
return 0;
}

Comments

  • You've made a little mistake in the following lines:
    .
    .
    .
    .
    char deck[53][32];

    initialize(deck);
    return 0;
    .
    .
    .
    .
    The code should look like this:

    .
    .
    .
    char deck[53][32];

    [b]initialize((char**)deck);[/b]
    return 0;
    .
    .
    .


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion