Atamba
can you find "iostream" in any of those paths?
Yes. It's located in /usr/include/c++/ directory, which is among the ones invoked by infer
Atamba
When I run: sudo find /* | grep -i iostream I get this output: /opt/infer-linux64-v1.1.0/lib/infer/facebook-clang-plugins/clang/install/include/c++/v1/iostream find: ‘/run/user/1000/doc’: Permission denied /usr/include/c++/10/iostream /usr/include/glib-2.0/gio/gsimpleiostream.h /usr/include/glib-2.0/gio/giostream.h /usr/include/glib-2.0/gio/gfileiostream.h /usr/include/taglib/tiostream.h I've trimmed the output.
Steven
where is /usr/include/c++/10/
Atamba
where is /usr/include/c++/10/
There's a line in https://t.me/programminginc/475357 that has it.
Steven
This is the dumped errors. Capturing in make/cc mode... MoreGreedy.cpp:2:10: fatal error: 'iostream' file not found #include <iostream> ^~~~~~~~~~ 1 error generated. Aborting translation of method 'main' in file 'MoreGreedy.cpp' Known incorrect assumption in the frontend: Expected source expression for OpaqueValueExpr Error: the following clang command did not run successfully: /opt/infer-linux64-v1.1.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-11 @/home/atamba/Documents/projects/steve/more_greedy/infer-out/tmp/clang_command_.tmp.60ce1e.txt ++Contents of '/home/atamba/Documents/projects/steve/more_greedy/infer-out/tmp/clang_command_.tmp.60ce1e.txt': "-cc1" "-load" "/opt/infer-linux64-v1.1.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib" "-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-" "-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1" "-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "MoreGreedy.cpp" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" "/opt/infer-linux64-v1.1.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/11.1.0" "-include" "/opt/infer-linux64-v1.1.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/x86_64-linux-gnu" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/backward" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/opt/infer-linux64-v1.1.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/11.1.0/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/atamba/Documents/projects/steve/more_greedy" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcxx-exceptions" "-fexceptions" "-o" "/tmp/MoreGreedy-ddbe77.o" "-x" "c++" "MoreGreedy.cpp" "-O0" "-include" "/opt/infer-linux64-v1.1.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h" "-Wno-everything"
I know, but seems this path doesn't exist in https://t.me/programminginc/475352
Atamba
I know, but seems this path doesn't exist in https://t.me/programminginc/475352
Sure. It's not listed there. Do we have a fix for this? Could it be a clang thing?
Steven
would you try add -include instruction to the compile commands
Steven
it seems to analyze your command, then migrate to its own clang
Atamba
Also, a side check. When I've filtered the output using: find /* | grep -i '/iostream' 1> list.txt 2>/dev/null I just realized that the header file is actually contained in the infer files. └──╼ $more list.txt /opt/infer-linux64-v1.1.0/lib/infer/facebook-clang-plugins/clang/install/include/c++/v1/iostream /usr/include/c++/10/iostream /usr/lib/python3/dist-packages/tornado/test/iostream_test.py /usr/lib/python3/dist-packages/tornado/iostream.py
Atamba
But, it's still invisible to the g++,gcc compilers.
Deepak Chaurasia
Hay whats the output of 10%10 1 or 0
Deepak Chaurasia
#include <stdio.h> int main() { int n, r, sum = 0; scanf("%d", &n); while(n > 0 ) { r = n % 10; sum = sum + r; n = n / 10; } printf("%d", sum); return 0; }
Deepak Chaurasia
Whats the output if enter 100
artemetra 🇺🇦
run and see
Deepak Chaurasia
It should 0 as per the program
SC0UNDREL
run and see
That's exactly what i wanted to say 😂
Deepak Chaurasia
Why 0?
100%10
Deepak Chaurasia
0+0
Deepak Chaurasia
Is zero
Pavel
100%10
But it's in a loop, loop will stop only when n == 0
Pavel
Is zero
And what will be value of n after the first iteration?
Pavel
1
It will be 1 after the second iteration, but anyway what's is result of 1%10?
Deepak Chaurasia
Sorry my bad
Pavel
.1
% is mod (reminder) operator, it returns what will be reminder after integer division
Deepak Chaurasia
Pavel
.
So, if you divide 1 by 10, the reminder after the division will be 0, or 0.1?
Deepak Chaurasia
0
Deepak Chaurasia
Sorry for misstype too much i am confusing
Pavel
0
1 / 10 = 0 1 - (1 / 10) * 10 = 1 (assuming it's integral math) You will get 1
Void
char a[50]; int i,j; for(i=0; ;i++) { scanf("%c",&a[i]); if(i=='\n') {break; } }
Void
Guys is there anything wrong with my code
Void
It can only read up to the tenth character
Pavel
char a[50]; int i,j; for(i=0; ;i++) { scanf("%c",&a[i]); if(i=='\n') {break; } }
you compare i with '\n' which has ascii code of 10. You probably wanted to compare a[i] with '\n' https://www.asciitable.com
Anonymous
Void
Because ASCII of \n is 10
Thanks i fixed it
Atamba
Void
rewritten. char a[50]; scanf("%s",a); Quite does the same.
But the question I'm working on requires counting the number of characters and numbers
Void
So i have to use %c
Atamba
So i have to use %c
Sure, just thought getchar() function would do fine too.
Void
Sure, just thought getchar() function would do fine too.
Yeah,i will try to do it again with getchar().
Atamba
I just like new ideas here.
Daulet
Can somebody explain me what that macros does? #pragma once #include <utility> #include <tuple> #include <type_traits> namespace Platform::Interfaces { #define THIS_REFERENCE_WRAPPER_METHODS(MethodName, TWrapped) \ constexpr auto&& MethodName() & { return static_cast<TWrapped&>(*this); } \ constexpr auto&& MethodName() && { return static_cast<TWrapped&&>(*this); } \ constexpr auto&& MethodName() const & { return static_cast<const TWrapped&>(*this); } \ constexpr auto&& MethodName() const && { return static_cast<const TWrapped&&>(*this); } #define VARIABLE_WRAPPER_METHODS(MethodName, VariableName) \ constexpr auto&& MethodName() & { return VariableName; } \ constexpr auto&& MethodName() && { return VariableName; } \ constexpr auto&& MethodName() const & { return VariableName; } \ constexpr auto&& MethodName() const && { return VariableName; } #define EXTENDED_BASE_TYPE(TExtended, TExtendedBase, TExtendable, TFirstExtender, TExtenders) \ TFirstExtender< \ std::conditional_t< \ sizeof...(TExtenders) >= 2, \ TExtended<TExtendable, TExtenders...>, \ std::tuple_element_t< \ 0, \ std::tuple<TExtenders<TExtendedBase<TExtendable>>...> \ > \ > \ > #define DECORATED_BASE_TYPE(TDecoratedBase, TFacade, TDecorated, TFirstDecorator, TDecorators)\ TFirstDecorator< \ TFacade, \ std::conditional_t< \ sizeof...(TDecorators) >= 2, \ TDecoratedBase<TFacade, TDecorated, TDecorators...>, \ std::tuple_element_t< \ 0, \ std::tuple<TDecorators<TFacade, TDecorated>...> \ > \ > \ > #define USE_ALL_BASE_CONSTRUCTORS(TSelf, TBase) \ template <typename ...TParams> \ TSelf(TParams&&... params) : TBase(std::forward<TParams>(params)...) {} }
Daulet
Can somebody explain me what that macros does? #pragma once #include <utility> #include <tuple> #include <type_traits> namespace Platform::Interfaces { #define THIS_REFERENCE_WRAPPER_METHODS(MethodName, TWrapped) \ constexpr auto&& MethodName() & { return static_cast<TWrapped&>(*this); } \ constexpr auto&& MethodName() && { return static_cast<TWrapped&&>(*this); } \ constexpr auto&& MethodName() const & { return static_cast<const TWrapped&>(*this); } \ constexpr auto&& MethodName() const && { return static_cast<const TWrapped&&>(*this); } #define VARIABLE_WRAPPER_METHODS(MethodName, VariableName) \ constexpr auto&& MethodName() & { return VariableName; } \ constexpr auto&& MethodName() && { return VariableName; } \ constexpr auto&& MethodName() const & { return VariableName; } \ constexpr auto&& MethodName() const && { return VariableName; } #define EXTENDED_BASE_TYPE(TExtended, TExtendedBase, TExtendable, TFirstExtender, TExtenders) \ TFirstExtender< \ std::conditional_t< \ sizeof...(TExtenders) >= 2, \ TExtended<TExtendable, TExtenders...>, \ std::tuple_element_t< \ 0, \ std::tuple<TExtenders<TExtendedBase<TExtendable>>...> \ > \ > \ > #define DECORATED_BASE_TYPE(TDecoratedBase, TFacade, TDecorated, TFirstDecorator, TDecorators)\ TFirstDecorator< \ TFacade, \ std::conditional_t< \ sizeof...(TDecorators) >= 2, \ TDecoratedBase<TFacade, TDecorated, TDecorators...>, \ std::tuple_element_t< \ 0, \ std::tuple<TDecorators<TFacade, TDecorated>...> \ > \ > \ > #define USE_ALL_BASE_CONSTRUCTORS(TSelf, TBase) \ template <typename ...TParams> \ TSelf(TParams&&... params) : TBase(std::forward<TParams>(params)...) {} }
@QNeko Can you?
Ludovic 'Archivist'
@QNeko Can you?
Not without a headache rn, I would have to preprocess the thing in my head since I am not home
Daulet
Not without a headache rn, I would have to preprocess the thing in my head since I am not home
Ok thanks for your answer. I wish you check this in more comfortable conditions
💕Toomi💕
Do you know how we use sifill??with #include <iomanip>
💕Toomi💕
???
S
Hyy
S
I m stuck in a problem someone help me
Ekal
Hello im a beginner in c language. Im currently making a final year project can u help me with this coding...
Mark
Hey everybody
Naufal
hello everyone, nice to meet you, here I am as a beginner and want to learn programming, and am looking for a complete c programming cheat sheet, if you have one, I beg you to ask, thank you
Naufal
does anyone have a cheat sheet c programming here ?
klimi
#paste please before posting such wall of text read the rules
Kriss
https://stackoverflow.com/questions/74002669/what-can-i-do-to-reduce-the-runtime-of-my-code
Anonymous
Hello people I'm having a hard time learning asio. I need resources for help
Kriss
Show me the exact problem statement.
https://codeforces.com/contest/1703/problem/D
Pavel
How can i reduce the runtime of my code?
The first comment is good in my opinion, you need to learn how to use profiler to see where are the slow parts in your code. First, it will give you faster feedback of what is slow and what is not, which is important for learning. Second, professionals use profilers/debuggers/sanitizers, they don't just stare at their code trying to understand what is wrong, they use tools to measure and visualize when they can.
Anonymous
https://codeforces.com/contest/1703/problem/D
You are using the wrong data structures. I would approach this problem this way: First I would store all the input strings in an unordered_set along with the vector. Then I will iterate through each string in the vector and for each string, I will iterate through its length and divide it up into two substrings. I will check if the two substrings are present in the unordered_set and mark its as 1 if that is the case. If I finish iterating without success, then I mark it as 0. For ex I will split the string abcd as a &bcd, ab&cd and abc&d and then check the unordered_set. This is much faster than your solution
Anonymous
that is a good way to solve , but i have to first learn unordered_set, thanks, i will try this approach for sure after learning unordered_set
You shouldn't be doing Competitive Programming (I don't like it though) without being familiar with data structures and algorithms.
Pavel
okay , i will have to learn how to use profiler than , thanks
If you see that some part is slow according the profiler but can't figure out why, come here and maybe we can help. But it would be good in any case if you can narrow down the problem yourself before that.
Daulet
Maybe friend functions can do it