iostream file


I have both of DevC++ and also code::blocks on my computer. but when i want to compile my code with code::blocks , it gives me an error:

error: iostream: No such file or directory


my code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include <iomanip>
using namespace std;

//Declaring the structure
struct DrinkInfo
{
   string name;
   double price;
   int number;
};

class DrinkMachine
{
    public:
    DrinkMachine();
    void displayChoices();
    DrinkInfo drinks[5];
};

//DrinkMachine::DrinkMachine
DrinkMachine::DrinkMachine()
{
   drinks[0].name="Cola";drinks[0].price=.75;drinks[0].number=20;
   drinks[1].name="Root beer";drinks[1].price=.75;drinks[1].number=20;
   drinks[2].name="Orange soda";drinks[2].price=.75;drinks[2].number=20;
   drinks[3].name="Grape soda";drinks[3].price=.75;drinks[3].number=20;
   drinks[4].name="Bottled water";drinks[4].price=1;drinks[4].number=20;
}

//DrinkMachine::displayChoices
void DrinkMachine::displayChoices()
{
    cout<<left<<setw(20)<<"Drink Name"<<setw(10)<<"Cost"<<setw(20)<<"Number in Machine"<<endl;
    for(int num=0;num<5;num++)
    cout<<setw(20)<<drinks[num].name<<set(10)<<drinks[num].price<<endl;
}

main()
{
    DrinkMachine drink;
    drink.displayChoices();
    system("pause");
    return 0;

}

Last edited on
this code returns different errors for me
line 11 and line 19: struct and class definition must end with a semicolon.
line 34: statement ends with a semicolon.
line 40: function name is "displayChoices()", not "dispalyChoices()".
line 37: main() must return "int".
line 32: the return type is needed here, ie, void DrinkMachine::displayChoices().
line 8: I think #include<string> is needed here, though no warning or error message appears.

Your code style is very good to make your code readable.
So far, however, his problem hasn't been answered.
Try here to make sure you haven't missed anything:
http://wiki.codeblocks.org/index.php?title=Installing_a_supported_compiler
(Remember, Code::Blocks isn't a compiler, it is an IDE.)
Hope this helps.

[edit] Chances are you'll have to manually add the MinGW directory to your Toolchain Executables directory list. If you are using Dev-C++, your version of MinGW is horribly out of date... you might as well delete it and download and install the latest version.
Last edited on
i recommend using MinGW as a compiler in Code::Blocks. you can download the mingw32 version of code blocks. this is way easier as you dont have to do all the cofiguration when installing the ide all you do is select GNU C/C++ compiler as your default.
closed account (NTDz3TCk)
I know!
edit this,
old:
#include <iostream>
#include <iomanip>
using namespace std;


New:
#include <iostream>
#include <iomanip>
using namespace std;

int main()

Topic archived. No new replies allowed.