klimi
all the problems?
klimi
what do I have to change right now ?
well the "most" bad thing is the scanf
the best for everyone
well the "most" bad thing is the scanf
okay I got it what do have to change from it
Mandelbröt
What algo does find function in c++ stl use in background ?
the best for everyone
klimi
any answer please ?
What's the question?
klimi
How to change the scanf? Look into the documentation for scanf
the best for everyone
ctype.h exist
sorry what is this ?
\Device\NUL
scanf receive pointer, not literal value
the best for everyone
\Device\NUL
so what is the correct answer
Have you learned pointer ?
\Device\NUL
Some variables are undefined, and did compiler gives any warn ?
the best for everyone
Have you learned pointer ?
yes but I didn't make pointer in it
the best for everyone
Some variables are undefined, and did compiler gives any warn ?
no the compiler didn't give me ant warn this reason why I couldn't know what is the problem exactly
klimi
https://en.cppreference.com/w/c/io/fscanf jsut read the format of the scanf
\Device\NUL
I only use scanf
scanf is fscanf to stdin
klimi
I only use scanf
sure, use stanf
klimi
the format is the same
the best for everyone
scanf is fscanf to stdin
I didn't understand so far now
the best for everyone
what is the mistake
klimi
I didn't understand so far now
scanf("%d to change it to lower case %c " ,&g,to_lower_case(f)); Explain this format string what it is supposed to match
mito
int max_of_four(int a, int b, int c, int d) { if (a > b) { if (a > c) { if (a > d) { return a; } else { return d; } } else { if (c > d) { return c; } else { return d; } } } else { if (b > c) { if (b > d) { return b; } else { return d; } } else { if (c > d) { return c; } else { return d; } } } } This is what I used for one of the problems in HackerRank website for finding the max of four numbers given.. The logic is simple, but I'm feeling there's a more elegant way to solve this .. Anyone know of any ? #cpp
mito
I don't want to use std::max()
mito
make a new variable int max, and set it to a. then check every other value with it, and if it's bigger, reassing it to max
int max_of_four(int a, int b, int c, int d) { int max; max = a > b ? a : b; max = c > max ? c : max; max = d > max ? d : max; return max; } Is this ok ?
mito
int max_of_four(int a, int b, int c, int d) { int max; max = a > b ? a : b; max = c > max ? c : max; max = d > max ? d : max; return max; } Is this ok ?
I just noticed that I could have done int max(int a, int b) { return (a > b) ? a : b; } and called max() like max(a, max(b, max(c, d)));
artemetra 🇺🇦
I just noticed that I could have done int max(int a, int b) { return (a > b) ? a : b; } and called max() like max(a, max(b, max(c, d)));
yes, this also works while the call stack increases by a little, it shouldn't be a problem
klimi
int max_of_four(int a, int b, int c, int d) { int max; max = a > b ? a : b; max = c > max ? c : max; max = d > max ? d : max; return max; } Is this ok ?
in this case you don't even need new local variable and you can just reuse a for example; but it might get optimized by compiler anyway
Anonymous
Hey I am new in c++ as I am trying to run my code after installing all compiler and other thing in vs code it shows that your program path doesn't exist in launch.json If any can help me plzz reach me out
꧁𓊈𒆜 ATreeShine 𒆜𓊉꧂
hi
mito
Do you click build option to build and run it ?
Anonymous
Problem is coming in launch jscon file
mito
Yup
I think, maybe your antivirus deletes the output executable file. Make a type exclusion or a folder exclusion in your anti virus settings.
mito
You can store the numbers in an array and then use a loop to find the max
found a better way. https://t.me/programminginc/465318
Муртазо
Gilded
Will ffmpeg -i filename.mkv filename.mp4 reduce quality
Harshit
#res
Pavel
Hey I am new in c++ as I am trying to run my code after installing all compiler and other thing in vs code it shows that your program path doesn't exist in launch.json If any can help me plzz reach me out
Hi, C and C++ don't use jsons, it is probably an error from your IDE or some tools that you use. Try to google this error with specifying your IDE/tools. Or try to find some tutorials for these or other IDE/tools (or tutorials for how to build with just a compiler without anything else)
Ludovic 'Archivist'
Hey I am new in c++ as I am trying to run my code after installing all compiler and other thing in vs code it shows that your program path doesn't exist in launch.json If any can help me plzz reach me out
The configuration for C++ in VS Code is a bit confusing. I recommend you consult the docs or that you compile and run from the command line until you have time enough to invest in understanding that clusterfuck
M Saifullah
Hey I am new in c++ as I am trying to run my code after installing all compiler and other thing in vs code it shows that your program path doesn't exist in launch.json If any can help me plzz reach me out
I suggest you to use Dev C++ (application name) for running integrated compiler for C and C++ in that application without need to setup in your computer.
Anonymous
I used this steps to setup .json file and c++ code is running successfully. Just give it a try https://code.visualstudio.com/docs/cpp/config-mingw
Pavel
If you want to call operator [] having a pointer, you need to dereference it first std::cout << (*m)[0];
Anonymous
Try m[0][0] instead
Dimka
hmm, interesting, is pointer[0] equal to *pointer?
Anonymous
hmm, interesting, is pointer[0] equal to *pointer?
When m is a pointer, m[0] is equivalent to *(m+0).
Anonymous
https://www.programiz.com/cpp-programming/library-function/cctype/tolower
klimi
what is the wrong in it its just I have passed the function in scanf
Can you explain this line of code? what it does? what's the input, what's the output? how it does?
X
Use ASCII table
Chri~
could someone explain to me how to get variables from a function outside the class in which it is declared?
Manuel
Return it, or make this variable static / global
the best for everyone
okay thank you
Anonymous
Yes, a lot about object oriented and classes. Want to explore gradually. Finding similarities between Embedded C++ and C++
Michel
Hi, I have this piece of code and when I compile I get the warning: warning: ‘struct ParticleSpecies’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor] Why is that a warning? What would be the best practice in this case?
Aristo
Has anyone read Effective C by Seacord?
Anonymous
How to read XML file in c programming language
Anonymous
How to read XML file in c programming language
Hi, i am using libxml2 opensource library for this. It has all required features. I used it on both linux and windows. https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home
Anonymous
Can you share code to read XML file using c
Try this: http://www.xmlsoft.org/examples/
Anonymous
Let me try and come back
Anonymous
Yep sure. If you still face issues let me know i will share small example to read xml file.. 👍🏻
Michel
Have you defined virtual destructor..??
virtual ~ParticleSpecies() = default; I did this, it got rid of the warning message but I have no idea if it solves the issue the compiler is trying to warn me about. Just followed this.