| | |
Dev C++ Hates me
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
hi,
you have to make your programs to wait for KeyPress or if you write in windows os then send system("PAUSE"); message.
the other solution is to run all your program from command prompt (cmd.exe)
here is some example code:
you can use cin.get(); instead of system("PAUSE");
thats all
i hope this will help you.
you have to make your programs to wait for KeyPress or if you write in windows os then send system("PAUSE"); message.
the other solution is to run all your program from command prompt (cmd.exe)
here is some example code:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { char* name; cout << "Enter your name, please: " << endl; cin >> name; cout << "Your name is: " << cin << endl; system("PAUSE"); return 0; }
you can use cin.get(); instead of system("PAUSE");
thats all

i hope this will help you.
Винаги Ñ?е цели в луната, така и да пропуÑ?неш, пак ще Ñ?и Ñ?ред звездите!
by ludesign
by ludesign
Hi,
excuse me it's all my fall, i was hurry during writing this post because my boss was looking around my desk .. hehehe
so the problem line is:
it should be name instead of cin.
and here is another one example but this time we get the whole line:
excuse me it's all my fall, i was hurry during writing this post because my boss was looking around my desk .. hehehe
so the problem line is:
C++ Syntax (Toggle Plain Text)
cout << "Your name is: " << cin << endl;
it should be name instead of cin.
and here is another one example but this time we get the whole line:
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main() { char myName[256]; cout << "Enter your name, please: " << endl; cin.getline(myName, 256); cout << "Your name is: " << myName << endl; system("PAUSE"); return 0; }
Винаги Ñ?е цели в луната, така и да пропуÑ?неш, пак ще Ñ?и Ñ?ред звездите!
by ludesign
by ludesign
hi,
my english isn't perfect but i'll try to explain you:
using namespace std; telling to your compiler that we will using functions who belong to name space std and then you can use all function who belong to this name space wihtout to telling that to your compiler each time you using them.
for example i'll write you the same program but without defini the name space:
i hope you will understand what i'm trying to explain you
and for the array i prefer to use arrays for more reasons.
it this example i using it to tell my program that name longer that 256 chars is not allowed and the program will display only 256 chars.
that's it ... if you want you can change array size to 5 and to try enter more that 5 chars
my english isn't perfect but i'll try to explain you:
using namespace std; telling to your compiler that we will using functions who belong to name space std and then you can use all function who belong to this name space wihtout to telling that to your compiler each time you using them.
for example i'll write you the same program but without defini the name space:
C++ Syntax (Toggle Plain Text)
#include <iostream> int main() { char myName[256]; std::cout << "Enter your name, please: " << std::endl; std::cin.getline(myName, 256); std::cout << "Your name is: " << myName << std::endl; system("PAUSE"); return 0; }
i hope you will understand what i'm trying to explain you

and for the array i prefer to use arrays for more reasons.
it this example i using it to tell my program that name longer that 256 chars is not allowed and the program will display only 256 chars.
that's it ... if you want you can change array size to 5 and to try enter more that 5 chars
Винаги Ñ?е цели в луната, така и да пропуÑ?неш, пак ще Ñ?и Ñ?ред звездите!
by ludesign
by ludesign
that is half c, half c++. If you want a code in C++, it would look like this:
If you want to get see what is written, you can always use the cmd. If you know to use DOS, using cmd wont be difficult for you.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <string> using namespace std; int main( void ) { string name; char buff[257]; cout << "Your name: "; cin.getline( buff, 257 ); name = buff; cout << "Your name is " << name << endl; system( "PAUSE" ); }
Revenage is a dish best served cold.
50|2|2Y 4 |34|) 3|\|6|_|5|-| ![]() |
Similar Threads
- Dev-C++, GLUI linker error, undefined reference (C++)
- Are there any Dev C++ tutorial out there? (C++)
Other Threads in the C++ Forum
- Previous Thread: edit a field using c++
- Next Thread: wxWidgets events Connect or event table?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count data delete deploy desktop developer directshow dll download dynamic encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






