Skip to content

abdoachhoubi/morse.c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

C MORSE

C MORSE is a MORSE to ASCII converter and vice versa.

How to use?

Clone the repo to your local machine and run the command make
This will produce a new program called morse.
Usage:

# SYNOPSIS
./morse -s [string1]	[string2]	[string3]	...
./morse -d [morse rep1]	[morse rep2]	[morse rep3]	...

# DESCRIPTION
# -s: converts a string into morse code
# -d: converts a morse code into string

MORSE Code table:

static const char
	*const digit[] = {
	"-----",
	".----",
	"..---",
	"...--",
	"....-",
	".....",
	"-....",
	"--...",
	"---..",
	"----.",
},
	*const alph[] = {
	".-",
	"-...",
	"-.-.",
	"-..",
	".",
	"..-.",
	"--.",
	"....",
	"..",
	".---",
	"-.-",
	".-..",
	"--",
	"-.",
	"---",
	".--.",
	"--.-",
	".-.",
	"...",
	"-",
	"..-",
	"...-",
	".--",
	"-..-",
	"-.--",
	"--..",
};

static const struct punc {
	char c;
	const char *morse;
} other[] = {
	{ '.', ".-.-.-" },
	{ ',', "--..--" },
	{ ':', "---..." },
	{ '?', "..--.." },
	{ '\'', ".----." },
	{ '-', "-....-" },
	{ '/', "-..-." },
	{ '(', "-.--." },
	{ ')', "-.--.-" },
	{ '"', ".-..-." },
	{ '=', "-...-" },
	{ '+', ".-.-." },
	{ '\0', NULL }
};

All contributions are welcomed!

About

Morse code converter using C and Makefile

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published