Thread: Im new an trying to make a calculator

  1. #16
    Registered User
    Join Date
    Feb 2002
    Posts
    32

    strcmp

    strcmp?

    and how would you clear the screen like

    clrsrn() or somthin like that?

  2. #17
    Pygmy Monkey ErionD's Avatar
    Join Date
    Feb 2002
    Posts
    408
    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

  3. #18
    Unregistered
    Guest
    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
    ADD
    150
    -------> Total

    which in actual assembly would be

    mov ax,64h
    add ax,96h
    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.

  4. #19
    Registered User
    Join Date
    Feb 2002
    Posts
    32

    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

  5. #20
    Registered User
    Join Date
    Feb 2002
    Posts
    32

    'strcmp' : undeclared identifier

    'strcmp' : undeclared identifier

    does strcmp require a certain header file?

  6. #21
    Registered User
    Join Date
    Feb 2002
    Posts
    19
    '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
    #include "aHeader.h"


    And yes there are a whole lot of header files included with visual studios. If you installed the help files you might want to spend a couple hours going through them like i did once


    Hope this stuff helps

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trying to make a KenGen ( for a game tool )
    By lonewolfy in forum C# Programming
    Replies: 4
    Last Post: 03-28-2007, 08:23 AM
  2. Basic Calculator
    By Surge in forum C Programming
    Replies: 18
    Last Post: 12-02-2006, 10:20 PM
  3. GUI Calculator - Critique
    By The Brain in forum Windows Programming
    Replies: 1
    Last Post: 02-25-2006, 04:39 AM
  4. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM
  5. 'functions' in make?
    By mart_man00 in forum C Programming
    Replies: 1
    Last Post: 06-21-2003, 02:16 PM