8
3
u/Jackplox May 25 '20
use %d when using the printf statement in place of the variable names
eg
printf(“(%d) %d - %d”, areaCode, prefixCode, lineCode);
(cant see your variables, so put the corresponding ones in the right order)
1
u/StochasticTinkr May 26 '20
Use “(%03d) %03d-%04d” instead. It shouldn’t matter for the area code/prefix, but definitely will for the suffix.
Without the 04, the phone number 2347890054 would print out as
(234) 789-541
2
u/malicart May 26 '20
Real answer is this is the wrong sub, try a learning one related to your language of choice.
1
1
1
1
u/StochasticTinkr May 26 '20
When working in the real world, Store phone numbers as strings, not long long. Real phone numbers have all kinds of crazy formats.
I know that isn’t relevant to your situation, but though it’s worth mentioning for the future.
1
May 26 '20
Unnecessary maths, just use string manipulation. If you are always given a 10 digit number as input... this is almost a one liner
2
u/[deleted] May 25 '20
Looks like your subtracting strings, will be an invalid operation.. remove some quotes