Strange things in a basic calculator written in C program. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Strange things in a basic calculator written in C program.

I have written a program for the Windows command prompt which consists of a calculator that performs basic operations (+,-,*,/) that receives as parameters: 1st operator, operand and 2nd operator, each separated by a space. During the debuggind, I made a block of code that list each one of the parameters given on the screen. The strange thing happens when I do a multiplication. The param that contains the sign (an * in this case) actually contains the name of the program (mycalc.exe). Why does this happen?

26th Sep 2017, 7:53 PM
zhoolf
zhoolf - avatar
3 Answers
+ 6
Hi, Ghost it's impossible to precisely catch your program bug without seeing it. So, do a favor and copy and paste your code into the playground and attach it to this post. Most likely you'll get some good solutions and advice about your problem.
26th Sep 2017, 8:19 PM
Babak
Babak - avatar
+ 6
Hi again Ghost I've tried to emulate your code (I'm not familiar with Windows programming) in VC++ 2010 and I managed to rewrite your code in this way (It's hardcoded but I guess you can get the point): https://code.sololearn.com/cAu0gBYsGnWr
26th Sep 2017, 10:59 PM
Babak
Babak - avatar
+ 1
@Babak Sheykhan (PERS) here is my code: https://code.sololearn.com/cGUL0fhE4A2P/?ref=app
26th Sep 2017, 9:04 PM
zhoolf
zhoolf - avatar