Hiya
I have a roblem concerning scanf that you might be able to help me with.
Example lines from text file (hope this formats right):
859613 3 Feb 4 Feb 10 Feb 11 Feb 17 Feb 18 Feb 24 Feb 25 Feb 14 Feb
779720
840683 3 Feb 4 Feb 10 Feb 11 Feb 17 Feb 18 Feb 24 Feb 25 Feb 2 Feb 9 Feb
heres the code ive been using so far:
sscanf(buffer, " %*li%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi%*[A-Za-z ]%hi",
&Crew->crewList[i].Bids[0],
&Crew->crewList[i].Bids[1],
&Crew->crewList[i].Bids[2],
&Crew->crewList[i].Bids[3],
&Crew->crewList[i].Bids[4],
&Crew->crewList[i].Bids[5],
&Crew->crewList[i].Bids[6],
&Crew->crewList[i].Bids[7],
&Crew->crewList[i].Bids[8],
&Crew->crewList[i].Bids[9]);
buffer contains 1 line from the sample data above.
Ugly eh ?
Anyways, what i need is to get the dates into an array. As you can see i dont know for sure how many dates are given, only that there will be no more than 10.
2 Questions.
1) This cant be the easiest way to do this right ? what are my options ?
2) My main problem is that when 10 dates are not given the empty array indexes wont be initialized correctly (gets filled with junk). How can i avoid this?
Its getting late and im not thinking straight anymore, so please forgive my (probably) stupid questions. I need to get this done though, so any help will be very appreciated.
Thanks