std::cin and std::cout isn't working

Hello all
the std::cin and std::cout aren't working for me correctly :(

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  #include <iostream>
#include "stdafx.h"
int main(){
	int count(0);
	double total (0.0);
	while(true){
		std::string
		std::cout <<"Next value please; ";
		double value;
		std::cin >> value;
		if(value > 9999.0)break;
		++count;
		total += value;
	}
	std::cout << "\nYou input " << count << " values. \n";
	std::cout << "Theur total is " << total  <<".\n";
	std::cout << "the arithmetic mean (average) of those values is " <<
		total/count << ".\n";
	return 0;
}


what could the reason be?
Thanks
What is line 7 std::string ? It looks as though it should not be there at all.
it also isn't working without string
Could you please give a more precise description than "it isn't working". What is the actual problem?
when I got to debug it says error - I am using visual studio 2010.
the thing I got is:
1>------ Build started: Project: Testing, Configuration: Debug Win32 ------
1> Testing.cpp
1>Testing.cpp(2): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1> Add directive to 'StdAfx.h' or rebuild precompiled header
1>Testing.cpp(8): error C2039: 'cout' : is not a member of 'std'
1>Testing.cpp(8): error C2065: 'cout' : undeclared identifier
1>Testing.cpp(10): error C2039: 'cin' : is not a member of 'std'
1>Testing.cpp(10): error C2065: 'cin' : undeclared identifier
1>Testing.cpp(15): error C2039: 'cout' : is not a member of 'std'
1>Testing.cpp(15): error C2065: 'cout' : undeclared identifier
1>Testing.cpp(16): error C2039: 'cout' : is not a member of 'std'
1>Testing.cpp(16): error C2065: 'cout' : undeclared identifier
1>Testing.cpp(17): error C2039: 'cout' : is not a member of 'std'
1>Testing.cpp(17): error C2065: 'cout' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
For some reason the iostream library which contains the definitions for std::cin and std::cout is not being included. That is your prolbem.
how do I include it?
try removing the spaces before the "#include <iostream>"
first line of the thing you posted
#include <iostream>
I suspect it is something to do with #include "stdafx.h" whuich isn't standard c++, rather it is specific to some compilers.

Beyond that, sorry, I can't help, though I'm sure someone else should be able to.
If you're using precompiled headers, #include "stdafx.h" must come before any other includes.
You set up your project to use precompiled headers which is what stdafx.h is for.

1. Create a new project.
2. In the first dialog box select console application.
3. In the next dialog box do not click Finish to accept the current settings. Instead click Next.
4. In the following dialog box deselect Precompiled header, then select Empty project. Make sure you deselect Precompiled header before selecting Empty project, otherwise Precompiled header will be still selected but dimmed out.
5. Now click Ok.
6. Add a new cpp file to your new project and copy and paste in your old code.
7. Remove the lines:

#include "stdafx.h"

std::string
thanx, now working :)
Topic archived. No new replies allowed.