After running my code for a calculator program this is what happens. It doesn’t allow you to enter another number. I’m not sure what I am missing. Code is located below.
Enter a number: 3.2
Enter operator: /
Process returned -1073741819 (0xC0000005) execution time : 5.624 s
Press any key to continue.
#include <stdio.h> #include <stdlib.h> #include <math.h>
int main()
{
No you can definitely use a pointer here, the important bit is passing an address for the newly “scanned” value to be stored in. So using the & (address-of) operator is quite common.
@system4502423996 you could equally use a named pointer here but then you’d need to dereference that same pointer when trying to compare it against character values later on. I would note though that your current compiler seems to mentioning issues related to C++ rules, if you’re writing C try to compile using C settings.
If you search around though you’ll probably find a fair amount of guidance warning against scanf for this (and suggesting things like fgets instead).