what does this code do

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maher5
    New Member
    • Oct 2007
    • 7

    #1

    what does this code do

    hi i had some help completing my assignment which i still dont understand fully.

    i dont know what this bit of the code means/do.

    the assignment was the morse code convertion.




    if(cinput[i] == 0x0a || cinput[i] == 0x0a) {
    cinput[i] = '\0';
    break;
    }

    i had the chars and ints defined as follow

    int i=0;
    char c, d, cinput[80];
    char alph[]="ABCDEFGHIJKLM NOPQR .........";


    char *morse[] = {
    ".-" , "-..." , "-.-." , "-.." , "." , /* a-e */
    "..-." , "--." , "...." , ".." , ".---" , /* f-j */
    "-.-" , ".-.." ............... .............


    then i had the following code resulting in an error msg if input is more than 80.

    for(i = 0; i < 80; i++) {
    cinput[i] = getc(stdin);
    if(i >= 79) {
    while( getc(stdin) != '\n');

    then that bit of the code comes in which i still dont know what it does..
    thanks ..
  • oler1s
    Recognized Expert Contributor
    • Aug 2007
    • 671

    #2
    It’s not entirely clear what code block you don’t understand. Repost, the code part you do not understand. You can indicate with a comment in the code the section you specifically cannot decipher. Remember to use CODE tags as specified in the sticky posts in the forum.

    Comment

    Working...