Author Topic: Cant make iomanip to work  (Read 5476 times)

Offline sedlacek

  • Single posting newcomer
  • *
  • Posts: 2
Cant make iomanip to work
« on: October 27, 2023, 03:41:06 am »
it straight sends me to a behind page with a few log errors on "namespace std"

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Cant make iomanip to work
« Reply #1 on: October 27, 2023, 03:53:57 am »
The rules https://forums.codeblocks.org/index.php/topic,9996.0.html

Code
namespace std;

Note: I am not a C++ Programmer; but, the problem is likely the ";" semi-colon you added or the fact you are missing an "using".

Note: As stated in the rules this is *not* a programming help web-site.

Tim S.

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 sedlacek

  • Single posting newcomer
  • *
  • Posts: 2
Re: Cant make iomanip to work
« Reply #2 on: October 27, 2023, 05:57:10 pm »
You got me wrong, i didnt write that code. I dont know if its a IDE problem or something else, but i tried to add the iomanip library to my project and it just sent me to that page i screen shotted. I was watching one of those youtube tutotrials and the same code worked fine on another IDE. This is what i actually coded:

ios worked fine and if i type the library name wrong, it gives me an error on my acutal code page.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: Cant make iomanip to work
« Reply #3 on: October 27, 2023, 10:02:55 pm »
I suggest posting a build log in code tags if you want help; posting a image will likely get you ignored.

https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

I also suggest reading the rules. https://forums.codeblocks.org/index.php/topic,9996.0.html

I will not be helping you again because as I have already stated I am not a expert C++ programmer.

Edit: My best guess is you accidently typed an ";" in a header file; so, re-installing your compiler might be the proper fix.
Edit2: Yes, that is the problem. You entered an ";" and a newline in file "ctime".

Code
namespace std
{
  using ::clock_t;
  using ::time_t;
  using ::tm;

Tim S.

« Last Edit: October 27, 2023, 10:28:09 pm by stahta01 »
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 blauzahn

  • Almost regular
  • **
  • Posts: 179
Re: Cant make iomanip to work
« Reply #4 on: October 27, 2023, 11:27:33 pm »
@sedlacek:

1. In your first screenshot gcc's error message shown by cb told you correctly where the code had a syntax error:

Code
C:\msys64\m...  58  error: expected '{' before ';' token

One might argue that gcc's message is not as helpful as it can be. Codeblocks OTOH did its job in displaying whatever the compiler in use suggests.

2. You did not
Quote
add the iomanip library
as it is just an include.

Please buy a decent C++-book and study it thoroughly. For C++ see https://isocpp.org/ and https://en.cppreference.com/w/. And please have a look into the links stahta01 suggested.

Thank you.