Assignment help please!!!

C

Cam

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
 
R

Rolf Magnus

Cam said:
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.
 
C

Cam

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
 
J

John Harrison

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
 
C

Cam

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


| > 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
|
|
|
 
P

Petec

Cam said:
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
 
C

Cam

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
 
V

Victor Bazarov

Cam said:
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
I shall, however, try to observe netiquette ...

Good.

V
 
K

Karl Heinz Buchegger

Cam said:
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


| > 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>
 
J

John Harrison

Cam said:
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
 
T

Thomas Matthews

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
 
R

Rolf Magnus

Cam said:
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.
 
A

ajim

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.
 
A

ajim

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help please 8
Code help please 4
Malicious Coding Help Please 5
Please help 7
Can't solve problems! please Help 0
Hello and Help please :-) 1
I dont get this. Please help me!! 2
Need help again please 19

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top