Anonymous
Anonymous
Shady
are address boundary error and segmentation fault the same?
Anonymous
are address boundary error and segmentation fault the same?
Address Boundary errors are one type of error that causes a segmentation fault. A segmentation fault may happen because of many reasons like for example out of bounds access, accessing an uinitialized value (traps may be caused), exhaustion of stack space, heap expanding into stack space etc etc.
Address boundary errors usually happen when you access memory that is illegal or not valid in your program at the point of access.
el
Hello guys, my robotic team searching for mentor or engineer for can mentor us about C++ for humanoid robots. This mentor get paid, if u interesting, just hit my DM, thankyou guys.
Anonymous
anybody knw about
ternory operator
Anonymous
?
Pavel
What do you mean by "call class", do you mean calling operator() on an object?
How do you store the objects? by value in the map or as pointers to some base class?
Pavel
Then you can use it right away from this
map[1].myFunction() if your class has myFunction function
Pavel
I think you didn't tell the whole story what you're trying to achieve, though
Pavel
You can do that as well
https://www.ideone.com/JxLPWW
Pavel
If that this doesn't answer your question, try to give more details of what you're trying to achieve
Pavel
It depends on what you want to achieve with this.
The most common way is to have a common parent class that has some interface for the operations that you plan to do.
E.g. you want to print message to different systems, you can have a class
class Writer {
public:
virtual void print(int value) = 0;
virtual ~System() {}
};
and then writer to console you can inplement it like this:
class ConsoleWriter : public Writer {
public:
void print(int value) override { // do some console specific stuff
}
};
Another way to do that can be to use std::any or std::variant.
Maybe there are other ways but it really depends on a task
Pavel
Armin
We need your contribution:
github.com/ArminGh02/sorting-algorithms
پویا رحیم
\Device\NUL
پویا رحیم
Jojo
Like to c/c++ ot
klimi
#ot ?
Levi
how can i get mingw 32bit version
Anonymous
Levi
Anonymous
heyy budyys
look i am learning c lang
and i am alone nobody close to me for discuss anything about c lang i need some enviroment around us that would be help me alot
Anonymous
Nana
Hi guys
Nana
I need a book that deal with C++ GUI
Nana
Okay. Thanks bro
مــــــــســــــعـــود
The book is for c++ with qt framework.
You can download it from https://qt.io
~
Write a program where two different queue structures use the same array. The first of the queues you will write will try to use the array from beginning to end, while the second will use it from the end to the beginning. Do not forget that queues may conflict and create a mechanism to prevent this. One queue may use more space in the array than the other queue.
~
mugish
Summers are back 🌞
In case you have started planning your summer, there’s something you must add to your list!
It’s time for the *Grand Summer Internship Fair* and brands like *Reliance, Oyo, Mahindra Holidays, Delhi Capitals* have already arrived with *1,500+ more companies*. Why is it extra hot? You get a *stipend as high as INR 40,000/month*.
I’m ready to experience a VIP journey through the GSIF Elite Zone and you should too because it doesn’t get any better. Participate here - https://internshala.com/grand-summer-fair-2022?utm_source=eap_telegram&utm_medium=19839808
مــــــــســــــعـــود
who can do this?
https://stackoverflow.com/questions/58051000/how-to-store-multiple-queue-in-array
Kate
Hello!
I am starting to learn C++. I want to run a ready-made example, but it does not work, there is an error:
E1696 cannot open source file "holoeye_slmdisplaysdk.hpp"
The advices from Google didn't help. I think I have done everything right. Paths to include and library are added to:
Project properties/Configuration properties/C/C++ General/Additional include directories
Project properties/Configuration properties/Linker/General/Additional library directories
Help me please!
江流儿
{
cout << "input [0-100] : ";
cin >> x;
if (x >= 0 && x <= 100)
break;
else
rewind(stdin);
}
江流儿
Can anyone tell me,
rewind(stdin);
what is it used for?
Prince Of Persia
江流儿
Prince Of Persia
E1696 cannot open source file "holoeye_slmdisplaysdk.hpp"
Prince Of Persia
Prince Of Persia
Prince Of Persia
LeBouy
A C program that reads input string and counts the number of each vowel character and the number of all other characters
Pavel
LeBouy
Pavel
how do I code it
You either need a buffer for the string (array of chars) big enough to fit the input and then iterate over it using a loop
Or you can just read input character-by-character (also in a loop)
You need to have two counter variables, and in the loop increment one of them when meeting a vowel and another when meeting not a vowel, then after the loop print these two counter variables
LeBouy
#include <stdio.h>
#include <stdlib.h>
int main()
{ char str1[110]= "Trinity";
int i, vowels, other;
//check if the character is a vowel
if ((str1[i] == 'a' str1[i] == 'b' str1[i] == 'c'
str1[i] == 'd' || str1[i] == 'e'))
{
++vowels;}
} else if
(str1[i] >= 'a' && str1[i] <= 'z'){
++other;}
{printf("Vowels: %d\n", vowels);
printf("Other: %d\n,", other);}
return 0;
}
LeBouy
that's how i did it but it keeps saying erros
Pavel
Pavel
Also try formatting your code, it is very difficult to read
Pavel
Pavel
#include <stdio.h>
#include <stdlib.h>
int main()
{ char str1[110]= "Trinity";
int i, vowels, other;
//check if the character is a vowel
if ((str1[i] == 'a' str1[i] == 'b' str1[i] == 'c'
str1[i] == 'd' || str1[i] == 'e'))
{
++vowels;}
} else if
(str1[i] >= 'a' && str1[i] <= 'z'){
++other;}
{printf("Vowels: %d\n", vowels);
printf("Other: %d\n,", other);}
return 0;
}
Your check for vowels is a bit strange, "b", "c" and "d" are not vowels, are they? And some other vowels are skipped. Ah ok I see that these are some test values.
If you want to make it more advanced (and you know how to make functions), you can make a function that checks if a character is a vowel and returns a bool, and then use that function in your if check.
Pavel
Pavel
I don't see more problems, try to fix the code and check the errors the compiler gives to you
LeBouy
%Nikita
Hello, guys.
How do you write code - in favor of readability, or in favor of speed? Because in some cases in C it is unreal to write fast and easy to read code. Just for example:
The code below is readable, but it creates new array, which will be used only one time. Waste of time and memory:
int op[3] = {item1, item2, item3};
func(op);
And this code is hard to read, but array is inlined:
func((int[3]){item1, item2, item3});
So which way is better?
klimi
Hello, guys.
How do you write code - in favor of readability, or in favor of speed? Because in some cases in C it is unreal to write fast and easy to read code. Just for example:
The code below is readable, but it creates new array, which will be used only one time. Waste of time and memory:
int op[3] = {item1, item2, item3};
func(op);
And this code is hard to read, but array is inlined:
func((int[3]){item1, item2, item3});
So which way is better?
if you turn on optimalizations, will the compiler optimalize it?
%Nikita
if you turn on optimalizations, will the compiler optimalize it?
I don’t trust compiler optimizations. It can just remove parts of my code. I don’t know exactly, but I remember that my compiler (gnu c compiler) just deleted part where I change const variable by pointer:
const int a = 5;
int *p = (int*)&a;
*p = 10;
Solution is to declare a as const volatile int. It took me about 40 minutes to understand wtf is going on.
Juli
Who can help me
Juli
Pls contact me in private
klimi
Misagh
Pavel
Pavel
And adding volatile to fix the code sounds bad (it's very slow)
Roman
LeBouy
C program that creates an 8-element array of type int, sets the elements to the first eight powers of 2, and
then prints out the values. Use a for loop to set the values, and for variety, use a do-while loop to display the
values?
Anonymous
LeBouy
Anonymous
Ludovic 'Archivist'
*happy hammer noises*
🙋🏻♂️
Hello guys