Reading STRING, INTEGER in the same line with Pascal
How do i read in pascal a string and an integer in the same line like the C's scanf("%s %d", str, &开发者_如何学Camp;n); version?
I am sorry, but I am pretty sure there is no way. You must read them separated.
Pascal does not have an equivilent of C's ...scanf()
functions. You will have to either find a third-party implementation, write your own implementation, or just parse the string directly.
If from stdin:
read(s); read(i);
If not, then you are out of luck for Borland's Pascal variants. Free Pascal (2.4+) inherited a variant from Apple(Standard Pascal derivative) variants that takes input from a string:
readstr(inputstr,s,i);
IIRC this is an Extended Pascal standard procedure that is commonly implemented by standard Pascal variants too, since it is basically a variant of the standard Pascal readln from input.
精彩评论