adajani1
asked on
read string highlow,highlow
Hi,
i have string structure:
Chighlow,highlow,highlow,h ighlow.... ......
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,
i have string structure:
Chighlow,highlow,highlow,h
C001200,210300,310310,400,
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,
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,
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?
>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?
ASKER
hi
yes three integer in one place array[0],,,,
next three integer in array[1] ......and so on
and ignore "C" and "," character......
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]?
I still don't understand. :(
From your original string: C001200,210300,310310,400,
You want to put 001200, 210300, and 210310 into array[0]?
ASKER
hi!
sorry for any confusion...
the thing is in the "zip.dat" file
have this format:
Chighlow,highlow,highlow,h ighlow.... ......
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.
sorry for any confusion...
the thing is in the "zip.dat" file
have this format:
Chighlow,highlow,highlow,h
or
C001200,210300,310310,400,
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
char *String = "C001200,210300,310310,400
sscanf (String, "C%d,%d,%d,%d", Int1, Int2, Int3, Int4);
:)
Good Luck,
Kent