Hello guys, i hope you all fine.
suppose that i have an array of characters containing data in this form
int@other_data
how can i get the int part alone and other_data ??
if for example we have data = 123@hello1245ss
i need to get
p1=123
p2=hello1245ss
i've tried the following function but it only works fine with string data
but fails if used with files (input/output read/write)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int segSplit(char* buf,int bufSize)
{
char * pnt;
pnt=strtok( buf, "@" ); //extract seqNum
if(pnt != NULL)
{
int seqNum = atoi(pnt); //string to int
int data_pos=strlen(pnt)+1;
int data_size=bufSize-data_pos;
memmove (buf,buf+data_pos,data_size); //extract data
buf[data_size]='\0'; ///* null character manually added */
return seqNum;
}
}