我一直在研究一些关于C的书,试图得到我的C腿(海腿!得到它?!).我刚从K&R书中完成了练习1-9,其参考是"编写一个程序将其输入复制到其输出中,用一个空格替换一个或多个空格的每个字符串." 我对我的代码发生了什么问题,但是 -
#include <stdio.h>
//Copy input to output. Replace each string of multiple spaces with one single space
int main(int argc, char *argv[]){
int ch, lch; // Variables to hold the current and last characters, respectively
/* This loop should 'put' the current char, then store the current char in lc,
* loop back, 'get' a new char and check if current and previous chars are both spaces.
* If both are spaces, do nothing. Otherwise, 'put' the current …
Run Code Online (Sandbox Code Playgroud)