Assignment help please!!!

Discussion in 'C++' started by Cam, May 28, 2004.

  1. Cam

    Cam Guest

    Hi everyone,

    I have written a C++ assignment using VS.NET and have been asked to modify
    it to run under Unix. I have removed all errors when compiling except that I
    can't get the Sun compiler to use the CONIO.H library.

    I have used the getche and getch functions that CONIO.H provides.

    I have added the CONIO.H file into the same directory as the *.cpp file but
    that doesn't seem to help.

    This has nothing to do with the completion of the assignment as the
    assignment has already been submitted. I just need to get it to compile
    under Unix.

    Is there an alternative library that will provide similar functions?

    ANY help would be greatly appreciated.

    Regards,

    Cam Telford
     
    Cam, May 28, 2004
    #1
    1. Advertising

  2. Cam

    Rolf Magnus Guest

    "Cam" <retsigerymmudathotmaildotcom> wrote:

    > Hi everyone,
    >
    > I have written a C++ assignment using VS.NET and have been asked to
    > modify it to run under Unix. I have removed all errors when compiling
    > except that I can't get the Sun compiler to use the CONIO.H library.


    CONIO.H is not a library. It's a header file.

    > I have used the getche and getch functions that CONIO.H provides.


    >
    > I have added the CONIO.H file into the same directory as the *.cpp
    > file but that doesn't seem to help.


    A header only tells the compiler, which functions are available. You
    still need an implementation of those functions.

    > This has nothing to do with the completion of the assignment as the
    > assignment has already been submitted.


    Your subject says something different.

    > I just need to get it to compile under Unix.
    >
    > Is there an alternative library that will provide similar functions?


    Have a look at ncurses.
     
    Rolf Magnus, May 28, 2004
    #2
    1. Advertising

  3. Cam

    Cam Guest

    Hi Rolf,

    Please pardon my poor syntax ... I am teaching myself C++ as I go.

    The code was written for an assignment and I have written and compiled the
    code using MS VS.NET. The lecturer asked if I could compile the code to run
    on the Unix system used by the Uni.

    As the assignment has already been submitted, I do not consider asking the
    NG for help cheating. If I believed that it was cheating, I wouldn't do it!

    I have not done a lot of work in C++ and was quite pleased with the fact
    that I was able to write the required code in the first place :eek:)

    The code was to get the user to input two signed, binary numbers and carry
    out arithmetic on these numbers without converting them to decimal to do the
    actual operations.

    I used getche to gather the input from the user and place each bit of the
    input into a separate array element. This made the binary processsing much
    easier.

    I have converted most of the code to run on the Sun system, but am unable to
    get the Sun system to recognise # include <conio.h>.

    Is conio.h a Microsoft only header?

    Will ncurses perform the same job as getche?

    Thanks for your help.

    Cheers,

    Cam
     
    Cam, May 28, 2004
    #3
  4. > I have converted most of the code to run on the Sun system, but am unable
    to
    > get the Sun system to recognise # include <conio.h>.
    >
    > Is conio.h a Microsoft only header?


    It's a platform specific header

    >
    > Will ncurses perform the same job as getche?


    It's also platform specific.

    Just use getchar as a replacement for getche. It does almost the same thing
    and its standard so will work on any C++ platform. getchar is declared in
    the header <stdio.h>. There's no need for platform specific functions for
    what you are attempting.

    john
     
    John Harrison, May 28, 2004
    #4
  5. Cam

    Cam Guest

    Thanks John,

    I'll give it a try.

    If I want to try and learn non-platform specific C++, where's a good place
    to start? Any good books?

    Cheers,

    Cam


    "John Harrison" <> wrote in message
    news:...
    | > I have converted most of the code to run on the Sun system, but am
    unable
    | to
    | > get the Sun system to recognise # include <conio.h>.
    | >
    | > Is conio.h a Microsoft only header?
    |
    | It's a platform specific header
    |
    | >
    | > Will ncurses perform the same job as getche?
    |
    | It's also platform specific.
    |
    | Just use getchar as a replacement for getche. It does almost the same
    thing
    | and its standard so will work on any C++ platform. getchar is declared in
    | the header <stdio.h>. There's no need for platform specific functions for
    | what you are attempting.
    |
    | john
    |
    |
    |
     
    Cam, May 28, 2004
    #5
  6. Cam

    Petec Guest

    Cam wrote:
    > Thanks John,
    >
    > I'll give it a try.
    >
    > If I want to try and learn non-platform specific C++, where's a good
    > place to start? Any good books?
    >
    > Cheers,
    >
    > Cam
    >


    Please don't top post.


    "Thinking in C++" by Bruce Eckel is availible legally and free online on his
    website, and is quite an excellent book.
    Bjarne Stroustrup's "The C++ Programming Language" is also a must-have book
    for standard C++.

    - Pete
     
    Petec, May 28, 2004
    #6
  7. Cam

    Cam Guest

    What's "top posting"?
     
    Cam, May 28, 2004
    #7
  8. Cam

    Buster Guest

    Cam wrote:
    > What's "top posting"?


    See the FAQ for this newsgroup (search the web for "C++ FAQ", then
    find the section on "netiquette").

    --
    Regards,
    Buster.
     
    Buster, May 28, 2004
    #8
  9. This is.

    Cam wrote:
    > What's "top posting"?
     
    Victor Bazarov, May 28, 2004
    #9
  10. Cam

    Cam Guest

    I looked up 'top posting' and that was not what I was doing. My reply to
    someone who was kind enough to answer my question was placed under their
    reply. I shall, however, try to observe netiquette ...

    OK ... so I have been advised that conio.h and getche are platform specific
    and that I should use stdio.h and getchar. The problem is that getchar does
    not seem to work the same way that getche does. Getchar seems to require
    something other than just the keypress.

    I need a non-platform specific function that will accept a single keypress
    and return the character code for the key pressed to allow the placement if
    individual characters into an array.

    I would like to assure anyone who is able to help me out that i am not
    getting the NG to do my homework.

    I have done loads of research on the net and through books prior to
    selecting getche as my initial function and haven't been able to find
    anything that does exactly the same job.

    An alternative would be REALLY appreciated.

    Thanks to all,

    Cheers,

    Cam
     
    Cam, May 28, 2004
    #10
  11. Cam wrote:
    > I looked up 'top posting' and that was not what I was doing. My reply to
    > someone who was kind enough to answer my question was placed under their
    > reply.


    Yes, it was. Your reply to John Harrison was _before_ the quoted text
    (message id <>). That's why "Petec" noted
    it to you.

    > I shall, however, try to observe netiquette ...


    Good.

    V
     
    Victor Bazarov, May 28, 2004
    #11
  12. Cam wrote:
    >
    > I looked up 'top posting' and that was not what I was doing. My reply to
    > someone who was kind enough to answer my question was placed under their
    > reply. I shall, however, try to observe netiquette ...
    >


    <pedantic mode on> Here is one of your posts:


    Thanks John,

    I'll give it a try.

    If I want to try and learn non-platform specific C++, where's a good place
    to start? Any good books?

    Cheers,

    Cam


    "John Harrison" <> wrote in message
    news:...
    | > I have converted most of the code to run on the Sun system, but am
    unable
    | to
    | > get the Sun system to recognise # include <conio.h>.
    | >
    | > Is conio.h a Microsoft only header?
    |
    | It's a platform specific header
    |
    | >
    | > Will ncurses perform the same job as getche?
    |
    | It's also platform specific.
    |
    | Just use getchar as a replacement for getche. It does almost the same
    thing
    | and its standard so will work on any C++ platform. getchar is declared in
    | the header <stdio.h>. There's no need for platform specific functions for
    | what you are attempting.
    |
    | john
    |
    |
    |

    <pedantic mode off>

    --
    Karl Heinz Buchegger
     
    Karl Heinz Buchegger, May 28, 2004
    #12
  13. "Cam" <retsigerymmudathotmaildotcom> wrote in message
    news:...
    >
    > OK ... so I have been advised that conio.h and getche are platform

    specific
    > and that I should use stdio.h and getchar. The problem is that getchar

    does
    > not seem to work the same way that getche does. Getchar seems to require
    > something other than just the keypress.
    >


    Typically getchar is buffered. It does read exactly one character, but
    nothing is read until a whole line has been entered.

    There is no exact equivalent for getche in standard C++. Given your
    application I can't see the need though.

    john
     
    John Harrison, May 28, 2004
    #13
  14. Cam wrote:
    [snip]
    > I need a non-platform specific function that will accept a single keypress
    > and return the character code for the key pressed to allow the placement if
    > individual characters into an array.

    [snip]

    >
    > An alternative would be REALLY appreciated.
    >
    > Thanks to all,
    >
    > Cheers,
    >
    > Cam
    >
    >


    Sorry, but there is no standard function for scanning a keyboard
    to determine when a key has been pressed or to get the code of
    the key that was pressed without buffering.

    The problem is that not all platforms are required to have
    keyboards. Of those that do have a keyboard, the operating
    system will buffer the input so that a user can modify the
    input before sending it to a program. This was to spare the
    applications from having to process "input editing keystrokes".
    Some operating systems allow users to change these settings.

    However, you can have your program call a generic function,
    such as "Get_Keypress". Inside this function will be a
    platform specific call. Create one version for each platform.
    Each version will be in a separate file (translation unit).
    Have your linking phase include the appropriate file for
    the platform you want. This is called creating a "wrapper".
    It allows the rest of your program to use one function call
    instead having to change the platform specific call everywhere
    in your code.

    An alternative, is to use preprocessor conditional statements
    to isolate the function:

    #if PLATFORM_MSDOS
    #include <conio.h>

    int Get_Keypress(void)
    {
    return getche();
    }

    #elseif PLATFORM_UNIX
    //...
    //...

    #else
    #include <exceptions>

    int Get_Keypress(void)
    {
    throw std::runtime_error("Platform does not support keypress.");
    }

    #endif.

    So to compile for MS-DOS platform, you would define PLATFORM_MSDOS
    in the compiler's command line, such as "-DPLATFORM_MSDOS"


    --
    Thomas Matthews

    C++ newsgroup welcome message:
    http://www.slack.net/~shiva/welcome.txt
    C++ Faq: http://www.parashift.com/c -faq-lite
    C Faq: http://www.eskimo.com/~scs/c-faq/top.html
    alt.comp.lang.learn.c-c++ faq:
    http://www.raos.demon.uk/acllc-c /faq.html
    Other sites:
    http://www.josuttis.com -- C++ STL Library book
     
    Thomas Matthews, May 28, 2004
    #14
  15. Cam

    Rolf Magnus Guest

    "Cam" <retsigerymmudathotmaildotcom> wrote:

    > Hi Rolf,
    >
    > Please pardon my poor syntax ... I am teaching myself C++ as I go.
    >
    > The code was written for an assignment and I have written and compiled
    > the code using MS VS.NET. The lecturer asked if I could compile the
    > code to run on the Unix system used by the Uni.
    >
    > As the assignment has already been submitted, I do not consider asking
    > the NG for help cheating. If I believed that it was cheating, I
    > wouldn't do it!


    That's good to hear. Anyway, I didn't suspect you were trying to cheat
    with this question.

    > I have not done a lot of work in C++ and was quite pleased with the
    > fact that I was able to write the required code in the first place :eek:)
    >
    > The code was to get the user to input two signed, binary numbers and
    > carry out arithmetic on these numbers without converting them to
    > decimal to do the actual operations.
    >
    > I used getche to gather the input from the user and place each bit of
    > the input into a separate array element. This made the binary
    > processsing much easier.
    >
    > I have converted most of the code to run on the Sun system, but am
    > unable to get the Sun system to recognise # include <conio.h>.
    >
    > Is conio.h a Microsoft only header?


    Yes.

    > Will ncurses perform the same job as getche?


    I didn't find a funciton getche in ncurses, but there is a function
    getch and some other similar functions. ncurses (or curses) is a Un*x
    library for console input/output. I think it's avaiable for Windows and
    other platforms, too. If it's installed on your Sun system, "man
    ncurses" or "man curses" in a shell might get you started. The
    function's man page might be available as curs_getch.
    Note that this is actually off-topic here, because curses is not a part
    of standard C++, so if you have further questions about it, you should
    use another newsgroup, like e.g. comp.unix.programmer.
     
    Rolf Magnus, May 28, 2004
    #15
  16. Cam

    osmium Guest

    Rolf Magnus writes:

    > > Is conio.h a Microsoft only header?

    >
    > Yes.


    No. Borland uses the same header name.
     
    osmium, May 28, 2004
    #16
  17. Cam

    jeffc Guest

    "Cam" <retsigerymmudathotmaildotcom> wrote in message
    news:...
    > What's "top posting"?


    If you quote someone (like I quoted you), then you should type below the
    quote, not above it.
     
    jeffc, May 28, 2004
    #17
  18. Cam

    ajim Guest

    Assignment making and homework in academic life has gotten out of hand. So it is not easy for us to prepare the assignment without the help of the experts. Acropolismentors provide us that help to the students of every stream, at the higher level.
     
    ajim, Feb 12, 2013
    #18
  19. Cam

    red floyd Guest

    On 2/12/2013 1:45 AM, ajim wrote:
    > Assignment making and homework in academic life has gotten out of hand. So it is not easy for us to prepare the assignment without the help of the experts. Acropolismentors provide us that help to the students of every stream, at the higher level.
    >


    FAQ 5.2

    http://www.parashift.com/c -faq-lite/dont-ask-hw-probs.html
     
    red floyd, Feb 12, 2013
    #19
  20. Cam

    ajim Guest

    Hey friends we don't know what you want in your assignment, and its not easy to describe i know. so you should contact with the person who can teach you by face. One more option is there to choose go with online service, acropolismentors can help you.
     
    ajim, Mar 21, 2013
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    552
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    667
    Big Brian
    Oct 14, 2003
  3. nagy
    Replies:
    36
    Views:
    1,041
    Terry Reedy
    Jul 20, 2006
  4. Chris
    Replies:
    34
    Views:
    1,567
  5. Daniel Fetchinson
    Replies:
    4
    Views:
    458
    Stephen Johnson
    Sep 11, 2008
Loading...

Share This Page