Well, if you want to do this with sscanf(), using strings, you pretty much have to know two things:
1. How sscanf() works.
2. How the input data are arranged in the input string.
You can teach yourself a lot of things by using printf() right after each application of sscanf():
Code:
sscanf( tempstring, "%c%5s", &Record.Cre.RecordType, &Record.Cre.CustomerCode);
printf(""\n\nRecordType = %d, CustomerCode: <%s>\n\n",
Record.Cre.RecordType,Record.Cre.RecordType);
Do it after each sscanf(), to see what' really happening.
Oh, by the way, consider this
Code:
for( loop = 0; loop < 20; loop++ )
{
Record.Cre.CustomerName[loop] = *string_ptr++;
}
What do you get with
Code:
printf("CustomerName: <%s>\n", Record.Cre.CustomerName);
Unless the array was initialized to all zero, you should put
Code:
Record.Cre.CustomerName[20] = '\0';
Even if it had been initialized to 0, I would always put it here, in case someone decides to change the initialization at some later time.
Does any of this give you anything more to work with? Wouldn't you really rather do it yourself? This stuff is kind of fun when it works.
Dave