Results 1 to 3 of 3

Thread: C question

  1. #1
    Senior Member
    Join Date
    Feb 2002

    C question

    I'm writing a program in C to get the computers internal speaker to transmit a morse code message.
    I have no problem transmitting a dot, I use the \a command inside of printf, but I can't repersent a dash, (three times the length of a dot). I've tried using \a three times in a row but it doesn't sound right so I was wondering does anybody know how I might achieve this.

    Also is there a command to stop a program operating for a length of time (such a sleep command or something) to put the spaces in the message?

    Thanks in advance,
    If you don\'t learn the rules nobody can accuse of cheating.

  2. #2
    Senior Member
    Join Date
    Jun 2002

    #include <time.h>
    stop a program operating for a length of time -

    sleep( time_t timeout_in_seconds )

    bet you didn't see that comin', but i don't like it because it tends to act differently for different computers because it is only as accurate as the system clock.
    other choices:

    msleep( long timeout_in_miliseconds )
    usleep( unsigned long timeout_in_microseconds )


    for windows C++ heads, it seems to be

    Sleep( int timeout_in_seconds )

    and you also have to #include <windows.h>. they all return int's

    there are functions in the <sound.h> for messing with the built in speaker.
    //must have IBMPC compatible hardware and software
    sound_beep( int frequency )
    sound_tone( int cycles, int uptime, int dntime )
    Hmm...theres something a little peculiar here. Oh i see what it is! the sentence is talking about itself! do you see that? what do you mean? sentences can\'t talk! No, but they REFER to things, and this one refers directly-unambigeously-unmistakably-to the very sentence which it is!

  3. #3
    Senior Member
    Join Date
    Mar 2003
    You might try using an ASCII code a'la ...

    printf( "\022");

    for your long dash. I can't remember what it was that
    I needed the same thing for a while back, but using
    the ASCII decimal ( or Hex ) code truned out to be
    the easiest way to get what I wanted, and it made
    iterration a lot easier too.
    Get OpenSolaris http://www.opensolaris.org/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.