Originally Posted by
rstanley
Have you attempted to write this yourself? We are not here to write the code for you.
Make an attempt to write this yourself, then if you have questions or problems, post your code, and we can give you advice.
Please read the
Forum Rules FAQs before posting here.
I did not mean to make it look like I just want someone to do my task, I just need some help. I wrote this so far:
Code:
#include <stdio.h>
#include <ctype.h>
int collapseSpaces{
int c1=getchar();
int c2=getchar();
while(isspace(c1) && issspace(c2)){ // my logic here was that I'd check if two consecutive characters are both spaces and if it is true, I'd replace them with a single space character
c1=c2=' ';
}
int main()
{
return 0;
}
I've also created a .txt file (I work in putty), in order to write some text to check if the program is working. As I stated above, I also need some help understanding how to print the modified text in main. Also I don't fully understand the newline part of the problem.