Thread: Help with very easy program

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    4

    Help with very easy program

    Hi guys,

    I'm a first time visitor here so hello to all.

    Could any of you post some C Code for a program to make a buzzer sound for 2 seconds please?

    Basically, it hasnt got to interface any hardware directly - just a theoretical program for a beginner in C Programming project

    PS - the adress for the speaker is 0x378 H and the Output of it is 0x379 (0x is Hexadecimal)

    Thanks a lot

  2. #2
    Bond sunnypalsingh's Avatar
    Join Date
    Oct 2005
    Posts
    162
    No One Will Write A Code For You Here....Post Some Code....And Tell Where You Are Stuck.....

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    sry about that - i wasnt aware of that rule.

    This is what I have so far


    Code:
    #include<conio.h>
    #include<stdio.h>
    #include<window.h>
    void main()
    {
    _Inp(0x378 , 0xff);
    	Sleep(2000);
    	_Outp(0x379, 0x00);
    }
    Last edited by plshelpme; 11-02-2005 at 10:51 AM.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    in MS-Windows normal programs cannot access ports directly. you might try PlaySound()

  5. #5
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    Hello,

    yes I know - this is just a theoretical program - its not actually going to be used - think of it as kinda for a school project

  6. #6
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    1) Don't void main.
    2) I could be wrong, but aren't the functions you're trying to use _inp(unsigned short) and _outp(unsigned short, int)?
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  7. #7
    Registered User
    Join Date
    Nov 2005
    Posts
    4
    OK, I know nothing about programming - this is a one-off thing im doing to help a friend of mine

    So if you could just re-write the code where I have gone wrong that woul dbe co0ol

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Try google for the prototypes of functions like inp. You probably won't get anyone here to write your code for you.

    BTW, it's <windows.h>, not <window.h>.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by plshelpme
    Hello,

    yes I know - this is just a theoretical program -
    There is no such thing as a "theoritical program". Programs are not written by theory alone. I could just type in a bunch of shi$ too, but that doesn't make it a computer program.

    MS-DOS 6.X and Win95 are the only two operating systems that can use the _inp() and _output() functions. Other versions of MS-Windows will forbid a program from using them.
    Last edited by Ancient Dragon; 11-02-2005 at 11:18 AM.

  10. #10
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    MS-DOS 6.X and Win95 are the only two operating systems that can use the _inp() and _output() functions. Other versions of MS-Windows will forbid a program from using them.
    Windows 98 works, too. And I imagine earlier version of DOS (like 3) would allow it as well.

    [edit]
    And it's _outp(), not _output() (I think).
    [/edit]
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Macro Program
    By daspope in forum Windows Programming
    Replies: 5
    Last Post: 04-25-2004, 04:02 AM
  4. my server program auto shut down
    By hanhao in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-13-2004, 10:49 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM