# Im new an trying to make a calculator

Show 80 post(s) from this thread on one page
Page 2 of 2 First 12
• 03-30-2002
helbovine
strcmp
strcmp?

and how would you clear the screen like

clrsrn() or somthin like that?
• 03-31-2002
ErionD
strcmp() is a function that takes 2 strings and if they are equal it returns zero. For example:

if(strcmp("Equal","Equal")==0) {
//they are equal
}

Yes, you can clear the screen.
Either you can include conio.h and use clrscr() and hope that you have it in conio or hope that you even have conio or you can make a search on these forums and find one of the custom made clrscr()'s
• 03-31-2002
Unregistered
For an actual calculator program you will need some knowledge of assembly, or at least how your CPU works.

A simple way to implement a calculator would be to use stacks.

For instance one stack calculation might be this

100
150
-------> Total

which in actual assembly would be

mov ax,64h
mov [total],ax

you could implement your own push and pop functions

push will push a value onto the stack at stack(0). Before doing this it will move all the contents of the stack down by 1 or down by the appropriate data width.

pop will take the value at stack(0) off and place it in the variable after the pop mneumonic. All contents on the stack are moved up accordingly and the stack size is decremented by the data width of the item taken off of the stack.

You could also implement registers similar to the CPU, but you will only need a subset of what the actual CPU has unless you want your calculator to be robust.

Creating a calculator is very similar to creating an emulator and can get very complex. You are essentially emulating a small CPU inside of the virtual calculator with your CPU.
• 03-31-2002
helbovine
conio
well i know i have conio... i have visual studio and use microsoft for a c++ compiler and i no they have alot of header files... plus i no i can add more i just dont no how :)
• 03-31-2002
helbovine
'strcmp' : undeclared identifier
'strcmp' : undeclared identifier

does strcmp require a certain header file?
• 03-31-2002
White Rider
Quote:

'strcmp' : undeclared identifier

does strcmp require a certain header file?
with MS VC++ i believe it can be found in string.h and also windows.h

clearing the screen is not part of VC++ but can be found on the FAQ of this board

in the project tab you can add header files to the project then