I put this and it doesnt write any letters in the screen.
include <iostream>
int main()
{
char response;
std::cin >> response;
using std::cout;
using std::endl;
cout << "Hello there.\n";
cout << "Here is 5: " << 5 << "\n" ;
cout << "The manipulator endl ";
cout << "writes a new line to the screen.";
cout << endl;
cout << "here is a very big number:\t" << 70000;
cout << endl;
cout << "Here is the sum of 8 and 5:\t";
cout << 8+5 << endl;
cout << "here's a fraction:\t\t";
cout << (float) 5/8 << endl;
cout << "and a very very big number:\t";
cout << (double) 7000 * 7000 << endl;
cout << "don't forget to replace jesse liberty ";
cout << "with your name..\n";
cout << "Ermis Vassilopoulos is a c++ Programmer!\n";
return 0;
}
The console box appears but it doesnt write anything in it. Why ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Perhaps it got offended by your last cout statement? :) It worked fine for me. When you run it, are you actually typing something and hitting enter so that it gets past the cin statement? The screen will remain blank until you type at least one character and hit enter.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please post your compile log. Before you say something like "But Wayne,that's all
you ever ask for" - I am looking for something very specific - you see, if you compile
a console program with -mwindows - you will not see your prints.
The compile log is on the tab labeled "Compile Log", NOT the tab labeled compiler,
and the right mouse button brings up the copy menu.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I tested your code I added another std::cin >> response; at the end so the window wouldn't close until I typed another char and hit enter. There are better ways but I'm lazy and a copy/paste was easy.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Have you read the thread titled "Please Read Before Posting a Question" - there
is a thread there that deals with the "keeping the window open" problem.
It also has a LOT of other useful information.
I encourage you to be patient. I doubt there are too many worthwhile things
that you have been good at in 3 days.
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-09-01
If you run this code from the IDE or from explorer, it will work (and does work), but you have to realise that when a program terminates, its window is closed by the OS. This is normal behaviour. Your code will print all that output, probably faster than you can perceive it, and then close the window. You need to add code to let it wait before closing the window.
And you also need to understand the behaviour of line bases console input, it may trip you up, and still appear to immediately close. Hint: You input a 'response' character, you press 'a', then '<enter>' - that's two characters.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2007-09-02
"line bases" -> "line based"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I put this and it doesnt write any letters in the screen.
include <iostream>
int main()
{
char response;
std::cin >> response;
using std::cout;
using std::endl;
cout << "Hello there.\n";
cout << "Here is 5: " << 5 << "\n" ;
cout << "The manipulator endl ";
cout << "writes a new line to the screen.";
cout << endl;
cout << "here is a very big number:\t" << 70000;
cout << endl;
cout << "Here is the sum of 8 and 5:\t";
cout << 8+5 << endl;
cout << "here's a fraction:\t\t";
cout << (float) 5/8 << endl;
cout << "and a very very big number:\t";
cout << (double) 7000 * 7000 << endl;
cout << "don't forget to replace jesse liberty ";
cout << "with your name..\n";
cout << "Ermis Vassilopoulos is a c++ Programmer!\n";
return 0;
}
The console box appears but it doesnt write anything in it. Why ?
Perhaps it got offended by your last cout statement? :) It worked fine for me. When you run it, are you actually typing something and hitting enter so that it gets past the cin statement? The screen will remain blank until you type at least one character and hit enter.
Please post your compile log. Before you say something like "But Wayne,that's all
you ever ask for" - I am looking for something very specific - you see, if you compile
a console program with -mwindows - you will not see your prints.
The compile log is on the tab labeled "Compile Log", NOT the tab labeled compiler,
and the right mouse button brings up the copy menu.
Wayne
ojkay when i wrote something and pressed enter, it did say something but so fast that i couldnt see.
My book says that if I use
char response;
std::cin >> response;
it wont be fixed
but no it doesnt work
Compiler: Default compiler
Executing g++.exe...
g++.exe "C:\Dev-Cpp\wewe.cpp" -o "C:\Dev-Cpp\wewe.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
Execution terminated
Compilation successful
Osito at first i got angry with you but then i laughed.
this shouldnt be happening (also me programming shouldnt eb happening)
When I tested your code I added another std::cin >> response; at the end so the window wouldn't close until I typed another char and hit enter. There are better ways but I'm lazy and a copy/paste was easy.
no still have the problem because its my third day in programming and i already hate it
Storm,
Have you read the thread titled "Please Read Before Posting a Question" - there
is a thread there that deals with the "keeping the window open" problem.
It also has a LOT of other useful information.
I encourage you to be patient. I doubt there are too many worthwhile things
that you have been good at in 3 days.
Wayne
If you run this code from the IDE or from explorer, it will work (and does work), but you have to realise that when a program terminates, its window is closed by the OS. This is normal behaviour. Your code will print all that output, probably faster than you can perceive it, and then close the window. You need to add code to let it wait before closing the window.
And you also need to understand the behaviour of line bases console input, it may trip you up, and still appear to immediately close. Hint: You input a 'response' character, you press 'a', then '<enter>' - that's two characters.
Clifford
"line bases" -> "line based"