basically i have a struct with some various char arrays and ints. i have already used these throughout the program when reading from a file so i dont really want to change these.
anyway i ask the user to input their address (it must be a full line of text - eg. 123 Fake St Fakeville 90210). i was wondering what others would use to read it in all at once.
as i said above i have done a read from file function (user has 2 options - from file, or from input) and used fgetc(...) to read it all in (including ints) and it worked fine.
scanf(...) - would i have trouble diferentiating between ints, chars, and strings? and would there be trouble if the user put in maybe 2 spaces between words instead of 1? and would there be trouble if a user put in 4 numbers for a street number when the maximum is 3?
getch(...) - do a char at a time and use while and for loops to go over extra spaces if there are any and continue to read in as chars like in my read from file function? and would getch allow the user to type it out on the screen or would i need putch with it?
or is there something else i could use?
heres my struct if that helps.
so what would people do themselves? maybe an example as well please.Code:char flat_unit[MAX][UNIT_MAX = 3]; int flat_number[MAX][NUMBER_MAX = 3]; char flat_divider[MAX]; int number[MAX][NUMBER_MAX = 3]; char street_name[MAX][STR_MAX = 256]; char street_type[MAX][STR_MAX = 256]; char suburb_name[MAX][STR_MAX = 256]; int postcode[MAX][POSTCODE_MAX = 4];
thanks so much to everyone.