📄 l16.2a
字号:
#printWrite a program which reads a file with lines of upto 200 characters and shortens them to 60 charactersby throwing away any characters past the first 60.Compile and test it; then type "ready".#once #create Refhoboken harrison newark roseville avenue grove streeteast orange brick church orange highland avenue east orange mountain station south orange maplewood millburn short hillssummit chatham madison convent station morristown summit chanew providence murray hill berkeley heightsgillette stirling millingon lyons basking ridgexxxxxxxxxxxxxbernardsville far hills peapack gladstone#once #create badinhoboken harrison newark roseville avenue grove streeteast orange brick church orange highland avenue east orange brick church orange highland avenue east orange brick church orange highland avenuemountain station south orange maplewood millburn short hillssummit chatham madison convent station morristown summit chatham madison convent station morristown summit chatham madison convent station morristownnew providence murray hill berkeley heightsgillette stirling millingon lyons basking ridgexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbernardsville far hills peapack gladstone#usera.out <badin >xxx#cmp Ref xxx#succeed/* one way to do this */ #include <stdio.h>main(){ char line[61]; int c, k; k = 0; while ((c = getchar()) != EOF) { if (c == '\n') { line[k] = 0; printf("%s\n", line); k = 0; } else if (k < 60) line[k++] = c; }}/* Note that this version works regardless ofhow long the lines are. If you use getline,is the same thing true?? */#log#next16.2b 10
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -