| | |
Quick Question
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 1
Reputation:
Solved Threads: 0
ok well i started out with making my own source code then compiling and running with Dev-C++ and when i run it, its working fine until the last line, here let me past my code
i know its stupid, i just started and wanted to do something, but ok when i get to the part "what grade are you in << mystr << "? "; and when i enter my grade or w/e the box just closes, is there any way to fix this, would i have to put something like Press "q" to quit or something like that? Any help would be nice, thankyou
C++ Syntax (Toggle Plain Text)
// just a test #include <iostream> #include <string> using namespace std; int main () { string mystr; cout << "Hello, whats your name? "; getline (cin, mystr); cout << "Hello " << mystr << ".\n"; cout << "What grade are you in" << mystr << "? "; getline (cin, mystr); cout << "Thats cool, I used to be in " << mystr << "too.\n"; cout << "Well i'm going to go now, goodbye."; return 0; }
Last edited by The Leprechaun; Oct 19th, 2006 at 1:43 am.
•
•
•
•
run the in a command prompt then ull be able to see all the output before it quits. or try placing system("PAUSE") before the return statement, but i think thats bad practise to do that Its bad practice to use system calls to achieve such a trivial function.
Better use
getchar() if using C and cin.get() when using C++. I don't accept change; I don't deserve to live.
Yes that and many other things to be considered like the kind of overhead introduced when you call system functions for trivial tasks.
A very good tutorial by my friend and forum member Mr. WaltP can be found here which introduces some of the things which should be avoided.
http://www.gidnetwork.com/b-61.html
A very good tutorial by my friend and forum member Mr. WaltP can be found here which introduces some of the things which should be avoided.
http://www.gidnetwork.com/b-61.html
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- A quick question about "rank" (DaniWeb Community Feedback)
- Quick Question: Is J# the same thing as Java? (Java)
- Quick HijackThis question (Viruses, Spyware and other Nasties)
- A quick question (Game Development)
- quick question (C++)
- quick question (Geeks' Lounge)
- Question about 321Studios (Windows Software)
- AGP support video card question (Monitors, Displays and Video Cards)
- Quick question (Troubleshooting Dead Machines)
- Laptop LCD built into a car? (Monitors, Displays and Video Cards)
Other Threads in the C++ Forum
- Previous Thread: Pulling data from vectors
- Next Thread: Help with Assignment
Views: 2036 | Replies: 8
| Thread Tools | Search this Thread |
Tag cloud for C++
6 add api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion convert count data delete desktop directshow dll encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelper iamthwee ifstream input int integer java lazy lib linkedlist linux loop looping loops map math matrix memory microsoft newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort string strings struct studio system template templates test text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






