0

When encountering the following code,

while(c >= '0' && c <= '9') {x = x * 10 + c - 48; c = getchar();}

Astyle will format it to

while(c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
}

I don't want this to happen.

So how to set Astyle so that it does not format two braces on the same line?

Jochi Hua
  • 63
  • 5
  • There is only one true brace style, no? :P Does this answer your question? https://stackoverflow.com/questions/9052597/how-to-format-opening-braces-in-c-methods-with-astyle – 463035818_is_not_an_ai May 07 '21 at 11:47
  • @largest_prime_is_463035818 no – Jochi Hua May 07 '21 at 11:48
  • 1
    `c - '0'` is portable; `c - 48` is not. Also, you could use `std::isdigit` instead of `c >= '0' && c <= '9'`. As written, it works for digits, because `'0'..'9'` are required to be contiguous and increasing, but if you try to do that with letters, `std::isalpha` will always get the right answer, while hand-coding the test can go astray for character encodings that put other characters in the middle of the alphabetic characters. – Pete Becker May 07 '21 at 12:49

0 Answers0