Author Topic: Why doesn't C::B recognize #include <iostream>  (Read 4649 times)

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Why doesn't C::B recognize #include <iostream>
« on: October 23, 2015, 02:22:09 am »
I'm getting a red box next to #include <iostream> and a compiler error when I try to compile this simple C++ code, why?

Code
#include <iostream>

int main ()
{
 int i = 10;
float f = i;
std::cout << f;

return 0;
}
« Last Edit: October 23, 2015, 02:24:08 am by papagym »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Why doesn't C::B recognize #include <iostream>
« Reply #2 on: October 23, 2015, 09:43:07 am »
Most of the times this happens because the file has no valid ending for a c++-file and will therefore be treated as c-file or anything else.

Offline papagym

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: Why doesn't C::B recognize #include <iostream>
« Reply #3 on: November 18, 2015, 08:39:01 pm »
Sorry for the delayed reply I think the code was saved as a c file.
I believe this is a fault of the way Microsoft save a file.
It would be nice if we could get Microsoft to change the default saved file type from C to C++

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Why doesn't C::B recognize #include <iostream>
« Reply #4 on: November 21, 2015, 02:50:51 pm »
Sorry for the delayed reply I think the code was saved as a c file.
I believe this is a fault of the way Microsoft save a file.
It would be nice if we could get Microsoft to change the default saved file type from C to C++
This has nothing to do with microsoft, but how YOU safe the file.
If you create a new project you can select c or c++ and c::b will safe the file accordingly with c or cpp extension....