Was wondering if anyone could help me out with this portion of code

Was wondering if anyone could help me out with this portion of code

I'm checking through each character, using comments as my logic

Basically Im trying to remove all the whitespace from a text file while keeping the line format

Is my logic correct? And my usage of .get()? How do I delete the space?

fuck wrong one, its this one

>using automatic get function
Go manual or go home kid, this is no place for low tier homework

im a math major that has nearly 0 coding experience im sorry :((((

your problem is you are not using a good programming language like rust, haskell or common lisp

its required to use c++

Looks ok to me, but I think it would be better if you used
while(chn == ' '), so it would eliminate all consecutive whitespace, not just pairs

char ch;
while (!infile.eof()) {
infile.get(ch);
if (ch != ' ') {
cout

how would i delete the space?

1) design a state machine
2) implement it

this just prints everything that isnt a space, i need it to print the whole text file removing the spaces and keeping a space between each words
and for each line to stay on its line

>this just prints everything that isnt a space
Yes
>i need it to print the whole text file removing the spaces
Right, that's what it does
>and keeping a space between each words
That is contradictory to "removing the spaces"

Clarify what you want. Which spaces do you want to remove specifically?

well we don't have any idea what you are allowed or not allowed to do in your homework, but i'm pretty sure you could find 100 different ways to implement it in stackoverflow or random forums, just google it

all "extra" whitespaces, im sorry for confusion

so if its
"Hello there guys"

it should output
"Hello there guys"

Use sed, fagggot. Fucking java, for text editing.

i meant to add a bunch of spaces in between "hello" amd "there"

Your else statement comes one closing bracket too late.

sed -i 's/\x20\+/\x20/g' fagsfile

Oh, so you want to condense multiple adjacent spaces to a single space

char ch;
while (!infile.eof()) {
infile.get(ch);
if (ch != ' ' || infile.peek() != ' ') {
cout

holy shit okay!! Now i just need the tabs to be squished so that its line after line

so there's no blank tabbed lines in between the lines

thank you so much for this help you really are helping me out a ton

>Now i just need the tabs to be squished so that its line after line
Yet again, that doesn't make sense and you need to figure out how to use the English language to articulate what you actually want if you want anyone to help you.

Figure out how to implement regex in your language of choice.

s/\w+/ /g

Next!

it should read this, rather than if I were to press TAB a bunch of times after each line

You are terrible at conveying ideas

>300k starting any job i want

it should NOT have this output, but rather the one I am replying to

it shoudn't be this, but the one i screenshotted before

So you want to remove lines that only contain whitespace?

Use C
#include

int main() {
int c, flag;
flag = 0;
while ((c = getchar()) != EOF) {
if (c == ' ') {
if (flag == 0) {
putchar(c);
}
flag = 1;
} else {
putchar(c);
flag = 0;
}
}
}

it should be the final.png, but im getting the output from final2.png

std::unique_copy(std::istream_iterator(infile), std::istream_iterator(), std::ostream_iterator(outfile), [](char x, char y) { return std::isspace(x) && std::isspace(y); });

Something like that maybe..

You can tweak that lambda as you wish, but you shouldn't write stuff again that is already there..

no bueno :/

this kinda works
#include

// finish with whitespace, \n or eof at peek
void processWord() {
char ch;
while (!std::cin.eof() && !std::isspace(std::cin.peek())) {
std::cin.get(ch);
std::cout

sed -e 's/ +/ /g' file

>won't edit in-place
>doesn't escape +
>redundant use of e option

>retarded OP posts this thread over and over
>retarded Sup Forums users do his homework for him over and over
>nobody learns their lesson
people like you ruined my favourite board.