Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请教关于carriage return(ASCII code 13)的问题我把输入文件复制到本地文件input.in: Red Alder Ash Aspen Basswood Ash Beech Yellow Birch Ash Cherry Cottonwood Ash Cypress Red Elm Gum Hackberry White Oak Hickory Pecan Hard Maple White Oak Soft Maple Red Oak Red Oak White Oak Poplan Sassafras Sycamore Black Walnut Willow 然后把stdin重定向到input.in,这时读出的每一行字符都在‘\0’前加了一个carrige return,比如读入Ash, char str[31]; gets(str); 这时str中的元素是:'A' 's' 'h' CR '\0' 其中CR代表carrige return 我自己实现了一个gets:while( ch=getchar() && ch!='\n') str[i++] = ch; 仍然会在'\n'前读入一个CR 这时怎么回事? Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator