GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 12-Oct-2004, 20:42
sibyl03 sibyl03 is offline
New Member
 
Join Date: Sep 2004
Posts: 5
sibyl03 is on a distinguished road
Unhappy

Morse Code for C


Hi All,
i need to input ("English Letter") and print the output as Morse Code.
Rather new to C program. SO i don't know about strings etc...
But i do know that it involves char, put char(), print char () and probably even switches.
Can someone give me an idea how to begin doing?

thanks!
  #2  
Old 13-Oct-2004, 00:00
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,373
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by sibyl03
Hi All,
i need to input ("English Letter") and print the output as Morse Code.
Rather new to C program. SO i don't know about strings etc...
But i do know that it involves char, put char(), print char () and probably even switches.
Can someone give me an idea how to begin doing?

thanks!
The way I's do this is with character arrays.
Define a character array inbuf for your input of "English Letter".
Define a 2 dimensional array for the Morse Code:
CPP / C++ / C Code:
char inbuf[128];
char morse[256][10] = 
{    0,0,0,0 ... (32 times for non printing characters)
      "  ",         // space
      ".-..-.  ",   // quotes
      "",          // #
      "",          // $
      etc
      "-----  ", // 0
      ".----  ", // 1
      "..---  ", // 2
      "...--  ", // 3
      "....-  ", // 4
      ".....  ", // 5
and so on
                          

The 256 is for each ASCII character. Look up each character's value in an ASCII chart
The 10 is for the characters needed for each morse code symbol.

Read a sentence into inbuf and look at each character. Use that character as an index into the morse array to output the morse code for the character.
__________________

The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
 
 

Recent GIDBlogProblems with the Navy (Enlisted) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Formatting C / C++ code WaltP C Programming Language 1 06-Jan-2008 23:59
very difficult code - program gaurav_sting C++ Forum 1 16-Jun-2004 00:59
Speed up C++ code about 3d array! Truong Son C++ Forum 0 16-Mar-2004 21:52
Explain code in MS STL's binary_search rom C++ Forum 11 07-Mar-2004 20:11

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:40.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.