M
magix
Hi,
If I have string like below:
InputString= "@123456^BILL GATES^APR-2011 ?"
where @ - Start Character
^ - Separator
? - End Character
and it contains ID, NAME, and DATE
Pseudocode:
char * ID;
char * NAME;
char * DATE;
if ( (start char is @) AND (End Char is ?) AND (There are two ^ in string))
Then
{ //This is valid string
strncpy(ID, &InputString[1], 6); // ID has fix length
ID[6] = '\0'; // terminate the string
strncpy(NAME, &InputString[8], (Length of variable NAME Length) );
// NAME has variable length, but it is between two ^
NAME[strlen(NAME)] = '\0'; // terminate the string
strncpy(DATE, &InputString[position after the 2nd ^], (Length of
date between 2nd ^ and ?)); // Date is between 2nd ^ and ?
DATE[strlen(DATE)] = '\0'; // terminate the string
}
can help to transform into code (some string functions..i'm not too sure to
achieve and finding the length /position) ? Many thanks.
Regards.
If I have string like below:
InputString= "@123456^BILL GATES^APR-2011 ?"
where @ - Start Character
^ - Separator
? - End Character
and it contains ID, NAME, and DATE
Pseudocode:
char * ID;
char * NAME;
char * DATE;
if ( (start char is @) AND (End Char is ?) AND (There are two ^ in string))
Then
{ //This is valid string
strncpy(ID, &InputString[1], 6); // ID has fix length
ID[6] = '\0'; // terminate the string
strncpy(NAME, &InputString[8], (Length of variable NAME Length) );
// NAME has variable length, but it is between two ^
NAME[strlen(NAME)] = '\0'; // terminate the string
strncpy(DATE, &InputString[position after the 2nd ^], (Length of
date between 2nd ^ and ?)); // Date is between 2nd ^ and ?
DATE[strlen(DATE)] = '\0'; // terminate the string
}
can help to transform into code (some string functions..i'm not too sure to
achieve and finding the length /position) ? Many thanks.
Regards.