-2

I am trying to get my program to do some basic operations with 2 complex numbers, which user will enter. I am using complex.h. How can I use scanf() to scan for complex number(a+bi)?

ssekav
  • 1
  • 1

1 Answers1

0

scanf has no format specifier for complex numbers, only for "more or less" primitive types http://www.cplusplus.com/reference/cstdio/scanf/. Easiest solution would be to read the real and imaginary part into two single floats/doubles and construct the complex number from your temporary values.

hakononakani
  • 305
  • 2
  • 10