PDA

View Full Version : Little Help with visual c


SuPpa DuPpA fLy
09-04-2002, 02:02 PM
I need a visual c program that could receive regular text as input and give a morse code translation to the text as output;

Let me know if any of the programmers out there can help!

The program must be on Visual c
And done with pointers
this is a homework for my cousin, she is studing pc cience; and i don't hve time for this...

SuPpa DuPpA fLy
09-04-2002, 03:12 PM
Guys come on, i really need some help here :-(

richard
09-04-2002, 03:19 PM
The reason why you go to school, is to learn.

:confused:

ehanson
09-05-2002, 06:04 AM
That's very easy, but i have no time, would you post my galleries while i'm writing it? (Just joke)

howlingwulf
09-05-2002, 10:47 AM
I stopped doing homework for sandwiches a loooong time ago.

porntowers.com
09-05-2002, 02:44 PM
I do not know Morris code... Learning this would be the first step :P

I would probably use the methods included in the string.h header to manipulate the strings (replacement method).



String replace(char *original, char *replacement);




Where replacement is the Morris code equivalent. I would iterate through a loop and have parallel arrays contain each character and Morris code equivalent.



for(int i; i < original.length(); i++){
morris_code = original_string.replace(char original[i], char replacement[i]);
}


I am not positive on the syntax as I have been dabbling in too many languages lately, and I probably have combined available methods.

But that idea will get her started.

keyman
09-05-2002, 08:35 PM
Morris code? He said Morse code. Every programmer should know what Morse code is..

http://www.bobhays.com/KF9UL/morse.html

I'm not sure how indepth the ASCII to Morse Code translator has to be.. but basically:


int main( void )
{
char inp[256];

puts("Enter ASCII STRING:");
if(fgets(inp,256,stdin))
{
while(*inp)
{
ascii2morse(*inp); inp++;
}
}
return 0;
}

void ascii2morse( char asc )
{
char morse_buf[20];

/* do the lookup here */
if(mlookup(morse_buf,asc))
{
printf("%s ",morse_buf);
}
}


So all you gotta do, using that URL I gave you is write a translation array that has the morse code equivalents of each alpha numeric ascii character and have it return it to the provided buffer. The array index contains a pointer to the direct transation string. so my_array['A'] = pointer to string (".-"). Get it? That is one of the fastest ways to do it, as it only takes 1 multiplication to find the address of the direct translation string.

Ya, well I'm a geek.

porntowers.com
09-05-2002, 09:06 PM
<< I'm a Terrible speller

I know what Morse code is... I was saying I did not know the syntax of the language. Just like I know what Chinese is, but I don't know how to syntactically construct a sentence. But I conceit I will probably never learn Morse code... but I also do not have any need to learn it. Kinda brings me back to the days of using CB radios as walkie-talkies, though.