![]() |
|
#1
|
|||
|
|||
Microsoft Visual Studio .NET Morse Codehi,
CPP / C++ / C Code:
i have four space for each morse code for e.g. A is ".- " The program must use one of the character strings above and should include a function to accept a letter and return the equivalent Morse code for the letter. i need to use pointers to get each morse all the morse code will be same size four space.. i try to use this functions : CPP / C++ / C Code:
i try to converted into its integer ASCI code by a simple arithmetic operation. but still i can't it to work.. please help with this i real need help.. thank's Last edited by hello2001 : 21-Dec-2005 at 09:57.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
Re: Microsoft Visual Studio .NET Morse CodeHi, hello2001.
I tried to edit your post (to use code tags) and I think you were editing it at the same time too. In case there is anything missing from your post, it might be my fault. Please let me know if that happened. Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeQuote:
First of all, your array is incorrect. Here is one that has the proper number of characters in the proper order: CPP / C++ / C Code:
Note that by breaking it up into smaller groups, it is easier to troubleshoot (easier for me, that is). Quote:
In order to use strcpy, string2 must be a zero-terminated sequence of characters. There is only one string, and each 4-char sequence is not zero-terminated, so I don't see how strcpy is useful with the array that you gave. Quote:
That would have been my choice. How did you try it? Assuming array index 0 is for the first morse dit for 'A', then array index 4 will be for the first morse dah for 'B', array index 8 will be for 'C', etc. So for a given character from 'A' to 'Z', what will be the index? I got (character - 'A') * 4. You can copy the four characters starting into that index into your output string, one at a time. Don't forget to put an extra '0' at the end if you want to make a "string" out of the answer. Maybe you want to eliminate trailing space characters? For example is 'A' represented by Code:
Code:
Regards, Dave |
|
#4
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse Codei try to use pointers to get each morse.. i try to convert letters into ascii, but still i can't do it..
i have the morse code.. i went user to type in letter and program should returns morse code.. regards maj |
|
#5
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeQuote:
I showed you a correct array of Morse characters ( correct according to your description in your original post). I showed how to calculate the location of any Morse character in the array for ASCII chars 'A' through 'Z'. Did you try to implement any of it? In your first post you said that "i try to converted into its integer ASCI code by a simple arithmetic operation. but still i can't it to work." Show us what you tried. If someone wants to help you, then it would definitely help if he/she could know what you know and what you don't know. In other words, what do you know about pointers and arrays before you ran into this problem? For all we know, your program was correct but you just had a bad array. Ask specific questions and show your work on the problem so far. Regards, Dave |
|
#6
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeCPP / C++ / C Code:
from ascii to letters but i dont how to assign them to morse code Last edited by LuciWiz : 22-Dec-2005 at 09:38.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#7
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeQuote:
You are looking for a way to locate the Morse dits and dahs for an ascii char (looking for the position of the first Morse element corresponding to the ascii char). Once you know where to start, then you just copy the following elements to your output string. How about what I suggested previously (but now, I see that you are using ascii 'a' through 'z', not 'A' through 'Z)'? Here is how you can get the first Morse dit or dah for each ascii character: CPP / C++ / C Code:
Now, if you can get the first Morse dit/dah, you can copy the successive Morse elements into your output string, right? Regards, Dave |
|
#8
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeCPP / C++ / C Code:
is to locate the firt position of morse code.. which is locating.. i need to use index to display other morse code dit/dah.. also i went the user to type in the letter and then display the morse code.. thanks for help best Regards Last edited by LuciWiz : 24-Dec-2005 at 10:32.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#9
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse CodeQuote:
First I will give you a lecture (If you want to skip that and go directly to the example, it's OK, and I concede that the statments in the lecture are only an opinion. YMMV --- Your Mileage May Vary) [/begin lecture] Here's the thing: in order to create interesting programs in C (or any other language), you usually have to know something about the language and its library funcitons. If I give you an index value for a specific char in an array, and you can't tell me how to retrieve the values of that char and the following three, then you really need to learn something about the language, specifically arrays. Since you referred to "pointers" in your first post, you might have to learn something about pointers and their relationship to arrays. If you don't know how to get user input into a variable, then I suggest that you need to learn something about standard library I/O functions and make sure that you can apply them. For programs of this nature, I would recommend that you make the ASCII-to-Morse translation scheme be a separate function, but maybe you don't need to do this for your first pass at making it work. [/end lecture] On the other hand, sometimes when we know a little about the language and reading a book seems kind of boring and way too abstract, one way to learn is to find a seemingly simple problem that is interesting to us and dig into the language far enough to solve the problem. Fair enough. Here is an example of obtaining user input from the keyboard. I have indicated the place where you could put the translation procedure. Now, this isn't the first program that I would write as an example for someone who didn't have any exposure to the language at all, but you are far enough along to know about arrays and at least have been exposed to some terminology about pointers. This little example does show how to use standard C library functions to obtain and display user input, using an array of chars. "But," you say, "I wanted C++, not C." Well here's a clue: this is a perfectly valid guaranteed Standard C++ program as well as a perfectly valid guaranteed Standard C program. If you want to use getline() and cout rather than fgets() and printf() so that it is "real" C++, then I say: go for it! You will still be indexing through an array of chars, and that's the key. If you have any problems, then please post the entire program that you are trying. 1. Tell us what you did (what input did you give it). 2. Tell us what the output was (compiler errors?, compiled OK but bombed when executed? executed but gave wrong answer? or what???) 3. Tell us what you don't understand about what you expected to get and what you got. It wouldn't hurt to mention the compiler and operating system you are using. Sometimes it makes a difference for people trying to help. CPP / C++ / C Code:
Now, if you just want a program to translate ASCII to Morse, you can probably find examples on the web for all kinds of interfaces. If you are using this as a vehicle and motivation for learning C, you have to put some effort into learning C. Regards, Dave |
|
#10
|
|||
|
|||
Re: Microsoft Visual Studio .NET Morse Codei try to show all the morse from index but i coundn't show it..
|
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Introduction to .NET | LuciWiz | .NET Forum | 5 | 09-Aug-2007 05:53 |
| Visual Studio .NET 2003 problem in executing C source files | Debugger1 | C Programming Language | 14 | 04-Jun-2005 03:51 |
| What is "Ambigious symbol" ??*( a compilation error) | small_ticket | C++ Forum | 2 | 07-Jan-2005 22:10 |
| Problem with int mixed with char,... | leitz | C++ Forum | 17 | 07-Dec-2004 21:56 |
| Help! Some basal questions about MFC | xutingnjupt | MS Visual C++ / MFC Forum | 1 | 05-Dec-2004 04:38 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The