How to pass char** in python ctype?

2D char array pass by reference problems?

  • include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #include <time.h> void createDeck(char *DECK[52][4]); int main() { char DECK[52][4];//deck createDeck(DECK); } void createDeck(char *DECK[52][4]) { char DECK[52][4] = { {"AD"}, {"2D"}, {"3D"}, {"4D"}, {"5D"}, {"6D"}, {"7D"}, {"8D"}, {"9D"}, {"10D"}, {"JD"}, {"QD"}, {"KD"}, {"AC"}, {"2C"}, {"3C"}, {"4C"}, {"5C"}, {"6C"}, {"7C"}, {"8C"}, {"9C"}, {"10C"}, {"JC"}, {"QC"}, {"KC"}, {"AH"}, {"2H"}, {"3H"}, {"4H"}, {"5H"}, {"6H"}, {"7H"}, {"8H"}, {"9H"}, {"10H"}, {"JH"}, {"QH"}, {"KH"}, {"AS"}, {"2S"}, {"3S"}, {"4S"}, {"5S"}, {"6S"}, {"7S"}, {"8S"}, {"9S"}, {"10S"}, {"JS"}, {"QS"}, {"KS"} }; while(i<52) { printf("%s\n", DECK[i]); i++; } } I have no clue why it isn't working

  • Answer:

    char a[10] and char *a are in some sense sound 1-D character arrays char a[10][20], char *a[10], char ** etc are used for 2-D character arrays That way char *DECK[52][4] is not 2D character array. Rather it is 3D Also, you are redeclaring DECK in the function. One is formal argument and the other is local variable. char DECK[52][4] = you can not assign strings to a 2D character array. What really do you want? Do you want AD, 2D etc as strings?

Ryan Beagles at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.