1

Hi I'm having problems displaying a 2d char array.

Below is the functions which generates the data which the function below that will be using. it takes an input and creates a 2d char array of the tokens. From observing in VS2012 this works correctly.

Cheers

slasher53
  • 141
  • 1
  • 7
  • 1
    Very relevant: http://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope – chris Apr 11 '13 at 00:09

1 Answers1

0

Further to chris' comment (Refer to: Can a local variable's memory be accessed outside its scope?) , I feel to make your program work, you need to reconsider the allocation of tokens in TokStr function.

You could modify this declaration char *tokens[10]; to following piece of code. With this change, your code should work fine.

char **tokens;
tokens = malloc(10 * sizeof(char *));
Community
  • 1
  • 1
Ganesh
  • 5,880
  • 2
  • 36
  • 54