473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

easy question

max
Hi,
I'm verry new to cpp ( I think im using only C but n e way ) in my prog
I need a user to input a choice with cin >> myvar. Actually
mymar is type char but when I type something higher than 1 character, the
program just quits right away. What can I do to prevent this and not
having to play with char array ?

TIA,
Max.
Jul 19 '05 #1
6 1602

"max" <ma*@localhost.ca> wrote in message
news:pa***************************@localhost.ca...
Hi,
I'm verry new to cpp ( I think im using only C but n e way )
You need to find out which. C and C++ are distinct,
separate languages.
in my prog
I need a user to input a choice with cin >> myvar. Actually
mymar is type char but when I type something higher than 1 character, the
program just quits right away.
Must be that bug on line 37.
What can I do to prevent this and not
having to play with char array ?


Use a std::string with std::getline

Oh, and if you show us your code, we can determine
what the problem really is.

-Mike
Jul 19 '05 #2
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Au*****************@newsread4.news.pas.earthl ink.net
"max" <ma*@localhost.ca> wrote in message
news:pa***************************@localhost.ca...
Hi,
I'm verry new to cpp ( I think im using only C but n e way )


You need to find out which. C and C++ are distinct,
separate languages.


Stroustrup seems to be confused too. On p.21 of TC++PL we read:

"2.1 What is C++
C++ is a general-purpose programming language with a bias towards systems
programming that
- is a better C "
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)
Jul 19 '05 #3
"John Carson" <do***********@datafast.net.au> wrote in message
news:3f******@usenet.per.paradox.net.au...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Au*****************@newsread4.news.pas.earthl ink.net
"max" <ma*@localhost.ca> wrote in message
news:pa***************************@localhost.ca...
Hi,
I'm verry new to cpp ( I think im using only C but n e way )


You need to find out which. C and C++ are distinct,
separate languages.


Stroustrup seems to be confused too. On p.21 of TC++PL we read:

"2.1 What is C++
C++ is a general-purpose programming language with a bias towards systems
programming that
- is a better C "


Are you thinking that by saying C++ is a better C that Stroustrup is saying
the C++ language is a C language, only better?
You might just as easily say "A claw hammer is a better nail-driving device
than a screwdriver" means a claw hammer is a screwdriver, only better.
I think this is more in the context of what he means, i.e. C++ is better at
systems programming than C.
--
Gary
Jul 19 '05 #4
"Gary Labowitz" <gl*******@comcast.net> wrote in message
news:qY********************@comcast.com
"John Carson" <do***********@datafast.net.au> wrote in message
news:3f******@usenet.per.paradox.net.au...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Au*****************@newsread4.news.pas.earthl ink.net
"max" <ma*@localhost.ca> wrote in message
news:pa***************************@localhost.ca...
> Hi,
> I'm verry new to cpp ( I think im using only C but n e way )

You need to find out which. C and C++ are distinct,
separate languages.


Stroustrup seems to be confused too. On p.21 of TC++PL we read:

"2.1 What is C++
C++ is a general-purpose programming language with a bias towards
systems programming that
- is a better C "


Are you thinking that by saying C++ is a better C that Stroustrup is
saying the C++ language is a C language, only better?
You might just as easily say "A claw hammer is a better nail-driving
device than a screwdriver" means a claw hammer is a screwdriver, only
better.
I think this is more in the context of what he means, i.e. C++ is
better at systems programming than C.
--
Gary

No, what he means is that you can use C++ for C-style programming if you
want, and that for this purpose C++ is a better language than C (better type
safety, for example). Of course, C++ offers many features that are missing
from C and, of course, Stroustrup would say that it is generally better to
make use of them.

The point of my original post (expressed in an ironic style) was that I
believe that the OP was saying that he was programming in C++ but in a C
style --- exactly what Stroustrup was talking about. Accordingly, there was
no basis for suggesting that he was confused about the fact that C and C++
are different languages, just as it would be absurd to suggest that
Stroustrup was confused on the question.

Some people in this newsgroup have what seems to me to be a religious
obsession about distinguishing C and C++. Of course they are different
languages, but maintaining backwards compatibility with C was one of the
fundamental design goals of C++. Accordingly, it is quite natural, even
though not strictly correct, to refer to "programming in C" or "using only
C" when using C++ for C-style programming. Such phrases, strictly speaking,
are metaphors, but some people seem unfamiliar with metaphors or think they
should be banned.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 19 '05 #5
"John Carson" <do***********@datafast.net.au> wrote in message
news:3f******@usenet.per.paradox.net.au...
"Gary Labowitz" <gl*******@comcast.net> wrote in message
news:qY********************@comcast.com
"John Carson" <do***********@datafast.net.au> wrote in message
news:3f******@usenet.per.paradox.net.au...
"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Au*****************@newsread4.news.pas.earthl ink.net
> "max" <ma*@localhost.ca> wrote in message
> news:pa***************************@localhost.ca...
> > Hi,
> > I'm verry new to cpp ( I think im using only C but n e way )
>
> You need to find out which. C and C++ are distinct,
> separate languages.


With all this there seems to be a little joke. C++ tried to be backward
compatible with C. Then C changed. Is C++ still backward compatible with a
language that has moved on?
Maybe I should be banned. Anyway, thanks for the clarification.
--
Gary
Jul 19 '05 #6
"Gary Labowitz" <gl*******@comcast.net> wrote in message
news:ge********************@comcast.com

With all this there seems to be a little joke. C++ tried to be
backward compatible with C. Then C changed. Is C++ still backward
compatible with a language that has moved on?


This is apparently a matter of ongoing debate within the Standards
committees for the two languages. There are some who want to reconcile C99
and C++ and some who want to ignore the recent changes to C.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rdsteph | last post by:
I am having a lot of fun using the pyGoogle module ( http://pygoogle.sourceforge.net/ ) that uses the Google API. It is about as easy to use as I can imagine, and it is a lot nicer than using my...
0
by: | last post by:
I don't know SQL at all, but I have a problem now because I must use SQL in my PHP scripts. So please help me! I have 2 tables: id | name ----------- 1 | thing1 2 | thing2 3 | thing3 4 ...
5
by: LedZep | last post by:
What up, All I need to do is enter a last name in a text box, query a MSAccess database and display the name with the corresponding columns. This is no problem, but when there are more than one...
1
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
13
by: Ghislain Tanguay | last post by:
I have a compiled vb.net app and I want to give the user a choice to launch it from the start line command and pass it a parameter or not. How can I do that in my code? Is it possible? Ex. :...
1
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of...
23
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
6
by: Martin Bootsma | last post by:
I have a C question, which looks very easy, but no one here seems to know an easy answer. I have a function "powell" (from Numerical Recipes) which takes an argument of the type "double...
27
by: smnoff | last post by:
How does( or should user use) strncpy() to allocate enough memory space for the destination string, s1? I guess I am having trouble using strncpy as it seems to be giving me errors. And just...
9
by: rynTAU | last post by:
This is an easy question, I'm sure but I can't seem to figure it out. I'm trying to use the number_format() function to remove all decimal places from a number. $num = number_format($num,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.