V
v4vijayakumar
why the following code dumps core? TIA.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *agrv[])
{
int i = 0;
typedef char ca_t[20];
ca_t tokens[10];
char *token;
char *value = "hhjhjkh, ashdkja, dmnas,lkjlk";
token = strtok(value, " ,\t");
while(token != NULL)
{
strcpy(tokens, token);
++i;
token = strtok(value, " ,\t");
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *agrv[])
{
int i = 0;
typedef char ca_t[20];
ca_t tokens[10];
char *token;
char *value = "hhjhjkh, ashdkja, dmnas,lkjlk";
token = strtok(value, " ,\t");
while(token != NULL)
{
strcpy(tokens, token);
++i;
token = strtok(value, " ,\t");
}
return 0;
}