Removing first two elements of a string array in C
Posted
by
sandeep p
on Stack Overflow
See other posts from Stack Overflow
or by sandeep p
Published on 2012-12-06T04:25:28Z
Indexed on
2012/12/06
5:04 UTC
Read the original article
Hit count: 178
c
How can I remove first two elements of a string array? I have a code which is something like this.
char *x[10];
..............
..............
..............
char *event[20];
event[0]=strtok(x[i]," ");
event[1]=strtok(NULL," ");
event[2]=strtok(NULL," ");
event[3]=strtok(NULL," ");
event[4]=strtok(NULL," ");
event[5]=strtok(NULL," ");
for(i=2;i<length;i++)
{
strcpy(event[i-2],event[i]);
}
I observed that only event[0] has proper values. I printed the contents of event[][] before for loop and it displays correctly. Could you please tell me why this is wrong? and a possible solution?
© Stack Overflow or respective owner