Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Assignment help please!!!

Reply
Thread Tools

Assignment help please!!!

 
 
Victor Bazarov
Guest
Posts: n/a
 
      05-28-2004
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 <(E-Mail Removed)>). That's why "Petec" noted
it to you.

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


Good.

V
 
Reply With Quote
 
 
 
 
Karl Heinz Buchegger
Guest
Posts: n/a
 
      05-28-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| > 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
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
John Harrison
Guest
Posts: n/a
 
      05-28-2004

"Cam" <retsigerymmudathotmaildotcom> wrote in message
news:(E-Mail Removed)...
>
> 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


 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      05-28-2004
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

 
Reply With Quote
 
Rolf Magnus
Guest
Posts: n/a
 
      05-28-2004
"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 )
>
> 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.

 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      05-28-2004
Rolf Magnus writes:

> > Is conio.h a Microsoft only header?

>
> Yes.


No. Borland uses the same header name.


 
Reply With Quote
 
jeffc
Guest
Posts: n/a
 
      05-28-2004

"Cam" <retsigerymmudathotmaildotcom> wrote in message
news:(E-Mail Removed)...
> What's "top posting"?


If you quote someone (like I quoted you), then you should type below the
quote, not above it.


 
Reply With Quote
 
ajim
Guest
Posts: n/a
 
      02-12-2013
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.
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      02-12-2013
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-lit...-hw-probs.html

 
Reply With Quote
 
ajim
Guest
Posts: n/a
 
      03-21-2013
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with an Assignment(newb help) isaac2004 C++ 4 10-04-2007 08:44 AM
Assignment operator self-assignment check Chris C++ 34 09-26-2006 04:26 AM
Augument assignment versus regular assignment nagy Python 36 07-20-2006 07:24 PM
help with modelsim error (delay in signal assignment must be ascending) ra VHDL 3 08-04-2004 11:31 AM
Help: conditional attribute assignment itsme VHDL 1 07-23-2003 03:26 PM



Advertisments