LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2003, 09:44 PM   #1
sbilstein
Member
 
Registered: Apr 2003
Location: south florida
Distribution: red hat 8.0
Posts: 50

Rep: Reputation: 15
newbie c++ question


I've only programmed in qBASIC before and ion that there is this command that goes

INPUT "what is your name?", $name

Then whatever the person typed and then pressed enter would be stored in the string $name.

Is there any command or group of commands to do this in c++ (im just doing console programming" and if so what headers do i have to include?"
 
Old 07-27-2003, 09:55 PM   #2
jd121
Member
 
Registered: Jul 2003
Distribution: FreeBSD 5.1, Debian 3.0, Damn Small 0.4.2
Posts: 46

Rep: Reputation: 15
cout << "What is your name?";
cin >> name;

would take care of it.

You'd also need to include the iostram.h header file. (#include iostream.h)
 
Old 07-27-2003, 09:56 PM   #3
sbilstein
Member
 
Registered: Apr 2003
Location: south florida
Distribution: red hat 8.0
Posts: 50

Original Poster
Rep: Reputation: 15
so

str statement

cout >> "what is your statement"
cin >> statement

or something like that?
 
Old 07-27-2003, 09:58 PM   #4
Strike
Member
 
Registered: Jun 2001
Location: Houston, TX, USA
Distribution: Debian
Posts: 569

Rep: Reputation: 31
sbilstein, I suggest you hit up Google for "introduction to C++" or something like that. It'll be much easier for you to go through a tutorial than to keep asking questions here for how to do each thing.
 
Old 07-27-2003, 09:58 PM   #5
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
http://www.cprogramming.com/
http://www.cplusplus.com/doc/tutorial/
http://www.soldierx.com/books/Teach Yourself C++ in 21 Days/htm/fm.htm
http://www.uow.edu.au/~nabg/ABC/ABC.html

here are tonnes of c++ tutorial sites...you'll get a good head start with these sites

oh and an answer to your question maybe you could do something like this:


char string[256];
cout<<"Please enter a long string: ";
cin.getline(string, 256, '\n');
cout<<"Your long string was:"<<endl<<string;
return 0;
 
Old 07-27-2003, 10:09 PM   #6
sbilstein
Member
 
Registered: Apr 2003
Location: south florida
Distribution: red hat 8.0
Posts: 50

Original Poster
Rep: Reputation: 15
Ok thanks...Its just that most of the tutorials ive looked at go on about math and classes and objects...but never talk about a user defining variables. Thanks for the links.
 
Old 07-27-2003, 10:12 PM   #7
DrOzz
Senior Member
 
Registered: May 2003
Location: Sydney, Nova Scotia, Canada
Distribution: slackware
Posts: 4,185

Rep: Reputation: 60
no problem, happy reading
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Newbie Question. Please Help imfineru Linux - Newbie 8 08-20-2005 05:09 AM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 08:41 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM
RE: Samba question pls help {Newbie question} Radiouk Linux - Networking 4 06-03-2002 06:40 PM
Security question {newbie question} Radio Linux - Security 3 05-17-2002 06:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration