Howdy, Stranger!

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

Categories

Error in function.

yoxleryoxler Member Posts: 1
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

  • PerseusPerseus Member Posts: 2
    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;
    .
    .
    .


  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    _____ \ http://forcoder.org \ free video tutorials and ebooks about || PHP Perl Swift Java Delphi C# Ruby R Visual Basic .NET C Scratch Visual Basic PL/SQL C++ Python Objective-C JavaScript Assembly Go MATLAB F# Kotlin FoxPro Alice Scheme Transact-SQL Lisp ABAP D SAS ML Rust VBScript Lua Fortran Crystal Hack Erlang Clojure Apex Julia Dart Awk LabVIEW Logo Prolog COBOL Scala Ada Bash || ___________

Sign In or Register to comment.