C++ Help!!! (1 Viewer)

River

Senior Member
Jun 15, 2004
2,261
#2
you could atleast do the inputs and displays and set up the functions. Leave the functions blank and then someone might do the functions for ya.
 

Martin

Senior Member
Dec 31, 2000
56,913
#3
I don't quite understand how they want to you translate Morse to English and vice versa. Any hints? What was in chapter 5?

Riv, you know cpp? :flirt:
 

River

Senior Member
Jun 15, 2004
2,261
#4
++ [ originally posted by Martin ] ++
I don't quite understand how they want to you translate Morse to English and vice versa. Any hints? What was in chapter 5?

Riv, you know cpp? :flirt:
Nope, but I know some C+
 
OP

nedved34

Senior Member
Oct 3, 2002
3,919
  • Thread Starter
  • Thread Starter #7
    ++ [ originally posted by Martin ] ++
    I don't quite understand how they want to you translate Morse to English and vice versa. Any hints? What was in chapter 5?
    chapter 5 is about pointers and strings the last section of the chapter is about
    Fundamentals of Characters and Strings there are things like this in the chapter:
    -Reading strings
    Assign input to character array word[ 20 ]
    cin >> word
    Reads characters until whitespace or EOF
    String could exceed array size
    cin >> setw( 20 ) >> word;
    Reads 19 characters (space reserved for '\0')

    -cin.getline
    Reads a line of text
    Using cin.getline
    cin.getline( array, size, delimiter character);

    -cin.getline
    Copies input into specified array until either
    One less than the size is reached
    The delimiter character is input
    Example
    char sentence[ 80 ];
    cin.getline( sentence, 80, '\n' );

    -String handling library <cstring> provides functions to
    Manipulate strings
    Compare strings
    Search strings
    Tokenize strings (separate them into logical pieces)

    -char *strcpy( char *s1, const char *s2 );
    char *strncpy( char *s1, const char *s2, size_t n );
    char *strcat( char *s1, const char *s2 );
    char *strncat( char *s1, const char *s2, size_t n );
    int strcmp( const char *s1, const char *s2 );

    int strncmp( const char *s1, const char *s2, size_t n );
    char *strtok( char *s1, const char *s2 );
    size_t strlen( const char *s );
     
    OP

    nedved34

    Senior Member
    Oct 3, 2002
    3,919
  • Thread Starter
  • Thread Starter #8
    I have another assignment too and am working on it + i have c++ final for tommorow and am still alive :D
    Martin if u do this for me u will do a very very big favour :angel:
    btw i don't have to write the whole problem,i can get some grades if write
    some :)
     

    Martin

    Senior Member
    Dec 31, 2000
    56,913
    #9
    Well that doesn't exactly give an answer to how you are meant to map ascii to morse but I have an idea for that. But I'm still just learning c++ myself and I've never been a great coder so although I could do this, it would take me a long time and I just don't have it.

    For the mapping, consider an array of morse code that you assign as a constant. Then use the ascii table to compute the correct array index given the characters' integer value. The offset will be a constant, and you need to check for uppercase/lowercase. I know it's a little sketchy but that should give you an idea of how to proceed at least. Once you figure out the first problem, you'll see what to do next I think. Good luck. :)
     
    OP

    nedved34

    Senior Member
    Oct 3, 2002
    3,919
  • Thread Starter
  • Thread Starter #10
    I didn't get anything :frown:
    can u just write a few lines whatever u can.atleast i can show her that.cuz right now i can't think of anything i still have a lot to do:down:
     

    mikhail

    Senior Member
    Jan 24, 2003
    9,576
    #15
    N.B. You have to use functions and pass the parameters by reference using pointers.
    I don't get this thing against loops. If you don't use loops, the only thing to do is to have 26 segments of code which read the string and replace a particular letter (or itself capitalised) and replace it with itsMorse code equivalent and a space, before all of which you have to replace all spaces with double spaces (the rest above will add the third one).

    I'm afraid I've never been that handy with pointers, but if you want any code debugged, post it here and I'll see what I can do.

    Get a clear idea of your algorithm first, and the rest should become clear, at least if you use your help files right!
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)