QuestionQuick easy question

Posts 1–3 of 3 · Page 1 of 1
Quick easy question
I am completely new to using C++ the issue i'm having is with the Codeblocks IDE.
I made a simple calculator and it worked completely fine before but since I have re-opened it there seems to be an error..

#include <iostream>

using namespace std;

int main()
{
int a;
int b;
int sum;

cout << "How old are you? \n";
cin >> a;

cout << "Add X amount of years \n";
cin >> b;

sum = a + b;

cout << "You will be " << sum;


return 0;
}
The issue is with #include <iostream>
The log is saying " fatal error: iostream: no such file or directory "

Does anyone have any idea why this might be happening?

Update-

I've found out now that I need to change the file to a .cpp ( to compile it as a C++ ) rather than a .c ( to compile as a C ) is there anyway that I can set Codeblocks to automatically make it a .cpp file? or will it forever make me rename the file, close it, and re-open it to fix this issue?
Quote Originally Posted by Nooxie View Post

Update-

I've found out now that I need to change the file to a .cpp ( to compile it as a C++ ) rather than a .c ( to compile as a C ) is there anyway that I can set Codeblocks to automatically make it a .cpp file? or will it forever make me rename the file, close it, and re-open it to fix this issue?
I think you'll just have to do it, it's really not that much more work, or see if they have a .cxx filetype, that way it's slightly easier and it may even save it automatically as the proper type of c.
Quote Originally Posted by Nooxie View Post
I am completely new to using C++ the issue i'm having is with the Codeblocks IDE.
I made a simple calculator and it worked completely fine before but since I have re-opened it there seems to be an error..



The issue is with #include <iostream>
The log is saying " fatal error: iostream: no such file or directory "

Does anyone have any idea why this might be happening?

Update-

I've found out now that I need to change the file to a .cpp ( to compile it as a C++ ) rather than a .c ( to compile as a C ) is there anyway that I can set Codeblocks to automatically make it a .cpp file? or will it forever make me rename the file, close it, and re-open it to fix this issue?
Yeah, you get rid of Code::Blocks and get Visual studio.
Posts 1–3 of 3 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us