D
den_cse_here
Hello,
I've to take the input from a file in which data will be something like
this:
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
DESC~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
DESC~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+
I wrote the following code snippet to extract the data from the file:
flag = FALSE;
while(fgets(input,MAX-1,stream)!=0)
{
if(flag == FALSE)
{
sscanf(input,
"%[A-Z]~!+%[a-zA-Z0-9]~!+%d~!+%[A-Z]~!+%[A-Z]~!+%[A-Z]~!+%[A-Z0-9]~!+%[A-Z0-9]",
service, RR, &priority,Note, Port1, Port2, Route_code,
Route_code_desc);
flag = TRUE;
printf("%s %s %d %s %s %s %s %s\n",service,RR,
priority,Note,Port1,Port2,Route_code,Route_code_desc);
} // if ends here.
else // flag was TRUE.
{
sscanf(input,"%[A-Z]~!+%[A-Z]~!+%[A-Z]~!+%[A-Z0-9]~!+%[A-Z0-9]",
temp,Port1, Port2, Route_code,Route_code_desc);
if(strcmp(Port1,"") ==0)
{
flag = TRUE;
}
else
{
printf("%s %s %s %s %s\n",temp,Port1, Port2,
Route_code,Route_code_desc);
}
} // outer else part ends here.
} // While loop ends here.
I DON'T KNOW WHY THE ABOVE CODE IS GIVING ME THIS IN THE OUTPUT .
Specifically, I don't know why the code is ignoring the SG001 part in
the second loop
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
FENC~!+SG
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
Can anybody please help me to sort out the problem?
Thanks.
I've to take the input from a file in which data will be something like
this:
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
DESC~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
DESC~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+~!+
I wrote the following code snippet to extract the data from the file:
flag = FALSE;
while(fgets(input,MAX-1,stream)!=0)
{
if(flag == FALSE)
{
sscanf(input,
"%[A-Z]~!+%[a-zA-Z0-9]~!+%d~!+%[A-Z]~!+%[A-Z]~!+%[A-Z]~!+%[A-Z0-9]~!+%[A-Z0-9]",
service, RR, &priority,Note, Port1, Port2, Route_code,
Route_code_desc);
flag = TRUE;
printf("%s %s %d %s %s %s %s %s\n",service,RR,
priority,Note,Port1,Port2,Route_code,Route_code_desc);
} // if ends here.
else // flag was TRUE.
{
sscanf(input,"%[A-Z]~!+%[A-Z]~!+%[A-Z]~!+%[A-Z0-9]~!+%[A-Z0-9]",
temp,Port1, Port2, Route_code,Route_code_desc);
if(strcmp(Port1,"") ==0)
{
flag = TRUE;
}
else
{
printf("%s %s %s %s %s\n",temp,Port1, Port2,
Route_code,Route_code_desc);
}
} // outer else part ends here.
} // While loop ends here.
I DON'T KNOW WHY THE ABOVE CODE IS GIVING ME THIS IN THE OUTPUT .
Specifically, I don't know why the code is ignoring the SG001 part in
the second loop
FENC~!+SG001~!+1~!+TEST DATA~!+SGSIN~!+KRPUS~!+LOOP1~!+LOOP1
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
FENC~!+SG
DESC~!+KRPUS~!+GBSOU~!+LOOP2~!+LOOP2
Can anybody please help me to sort out the problem?
Thanks.