Link to home
Start Free TrialLog in
Avatar of adajani1
adajani1

asked on

read string highlow,highlow

Hi,

i have string structure:
   Chighlow,highlow,highlow,highlow..........
   C001200,210300,310310,400,...........999         (so zip range from 000 , 999)

and i want to put in an array of int

how can i ignore the char "C" and ","    ?
and get all low and high zip into array.?                  (for sreaching purpose)



thanks,


Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image


  char *String = "C001200,210300,310310,400"

  sscanf (String, "C%d,%d,%d,%d", Int1, Int2, Int3, Int4);


:)


Good Luck,
Kent
Avatar of adajani1
adajani1

ASKER

hi,

forget to memtion....

the string is in a "file.dat"
so i have to read in the file, ignore the "C" char and get the first 3 int
in array[0] and 2nd 3 int in array[1] then ignore "," char ......then so..on....
using sscanf() function....is it just sort out the structure.....right..?


thanks,
Hi adajani1,

>get the first 3 int in array[0]

This requires a bit of clarification.  You're suggesting that you want to put three integers into one place?
hi

yes three integer in one place array[0],,,,
next three integer in array[1] ......and so on
and ignore "C" and "," character......
Hi adajani1,

I still don't understand.   :(

From your original string:  C001200,210300,310310,400,...........999

You want to put 001200, 210300, and 210310 into array[0]?
hi!

sorry for any confusion...


the thing is in the "zip.dat" file
have this format:
          Chighlow,highlow,highlow,highlow..........
          or
          C001200,210300,310310,400,...........999

and i want to read from file and save it into an array like:
          array[0]=001
          array[1]=200
          array[2]=210
          ..................
          ...................
         
and "C" and "," ignore, not to put in an array.

ASKER CERTIFIED SOLUTION
Avatar of grg99
grg99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial