Reputation: 3888
I'm working on the project Euler problems, and #8 requires that you find the largest product of 5 consecutive numbers in a 1000-digit number. Does anyone know how I can format the number to be one long string over multiple lines instead of having it be one long string on one line?
Thanks!
Upvotes: 1
Views: 109
Reputation: 18652
The compiler will automatically concatenate string literals that are separated by white space. You can simply do:
const char bignum[] =
"73167176531330624919225119674426574742355349194934"
... more lines here ...
"71636269561882670428252483600823257530420752963450";
The resulting character array will be the same as if you typed one very long string literal. A link for the lazy.
Upvotes: 4
Reputation: 739
There is a big number library for c++ in https://mattmccutchen.net/bigint/
Upvotes: 0