Code::Blocks Forums

User forums => Help => Topic started by: sedlacek on October 27, 2023, 03:41:06 am

Title: Cant make iomanip to work
Post by: sedlacek on October 27, 2023, 03:41:06 am
it straight sends me to a behind page with a few log errors on "namespace std"
Title: Re: Cant make iomanip to work
Post by: stahta01 on October 27, 2023, 03:53:57 am
The rules https://forums.codeblocks.org/index.php/topic,9996.0.html (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.

Title: Re: Cant make iomanip to work
Post by: sedlacek 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.
Title: Re: Cant make iomanip to work
Post by: stahta01 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 (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 (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.

Title: Re: Cant make iomanip to work
Post by: blauzahn 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/ (https://isocpp.org/) and https://en.cppreference.com/w/ (https://en.cppreference.com/w/). And please have a look into the links stahta01 suggested.

Thank you.