strtok Unhandled exception;Access violation writing location

后端 未结 2 946
轻奢々
轻奢々 2021-01-26 08:09
#include 
#include 
#include 

char *matrix[10][10];
int main(void) {
    int i;
    char *list[4];
    char *words[20] = {
         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-26 08:25

      token = strtok((words[random]),search); 
    
      while(token!=NULL) 
       {
        length=strlen(words[random]);
    
        for( k=0;k

    This is messed and not what you intend. Change it to something straight, e. g.:

        for (k = 0, c = words[random]; token = strtok(c, search); c = NULL, ++k)
            matrix[i][k] = token;
    

提交回复
热议问题