1693
|
1
|
|
2 #include <string.h>
|
|
3 #include <stdlib.h>
|
|
4
|
|
5 void cutItem( char * in,char * out,char sep,int num )
|
|
6 {
|
|
7 int i,n,c;
|
|
8 for ( c=0,n=0,i=0;i<strlen( in );i++ )
|
|
9 {
|
|
10 if ( in[i] == sep ) n++;
|
|
11 if ( n >= num && in[i] != sep ) out[c++]=in[i];
|
|
12 if ( n >= num && in[i+1] == sep ) { out[c]=0; return; }
|
|
13 }
|
|
14 out[c]=0;
|
|
15 }
|
|
16
|
1852
|
17 int cutItemToInt( char * in,char sep,int num )
|
|
18 {
|
|
19 char tmp[512];
|
|
20 cutItem( in,tmp,sep,num );
|
|
21 return atoi( tmp );
|
|
22 }
|
|
23
|
|
24 float cutItemToFloat( char * in,char sep,int num )
|
|
25 {
|
|
26 char tmp[512];
|
|
27 cutItem( in,tmp,sep,num );
|
|
28 return atof( tmp );
|
|
29 }
|
|
30
|
1693
|
31 void cutChunk( char * in,char * s1 )
|
|
32 {
|
|
33 cutItem( in,s1,'=',0 );
|
|
34 memmove( in,strchr( in,'=' )+1,strlen( in ) - strlen( s1 ) );
|
|
35 }
|
1852
|
36
|