Anonymous
Use YouTube bro A lot of free courses on there
Yeah I know that but I can't ask him while watching his video,, but if its practical I can asked and my answers will be given immediately
ɛ n h ᴀ n c ɛ ґ 🧟‍♂️
Anonymous
Guide you about what?
C++ for beginner
Choun
Help me solve this pls ___________________ Write a program to create 2 classes: - Rectangle: has 2 functions: rectArea() and rectPerimeter() for calculate area and perimeter of rectangle . • Triangle: has 2 functions: triArea() and triPerimeter() for calculate area and perimeter of triangle.
Anonymous
Thanks rose👍👍
Anupam2.7
You end up summing the ASCII values of the numeric digits in the string.
Then how should i convert string to int, in order to add them?
Captain
Then how should i convert string to int, in order to add them?
Take the input as string and traverse through it and add (each character -'0' ) to the result.
Anupam2.7
Take the input as string and traverse through it and add (each character -'0' ) to the result.
How would i add it without typecasting it to int? And if i typecast it, it adds up it's ASCII values as Madhu said.
Captain
How would i add it without typecasting it to int? And if i typecast it, it adds up it's ASCII values as Madhu said.
You don't need to typecast it when you do arithmetic operations on char it will consider its ascii value. Suppose your input is 1234 For first iteration the addition will be '1'-'0'=49-48=1 which will add your integer 1 to the sum. Same is for 2 etc.
Anonymous
Hey guys How do I print prime number using c++ programming
Marlo
run a loop then use a condition to check if the number is even or not using modulus/remainder operator
I can do everything. They only think which i need it's just the way that the odd numbers going out of the loop. I don't know how to write this.
İbn
Using pointers, locate the int main() function in RAM and print it ?
Shahadat Shanto
Using pointers, locate the int main() function in RAM and print it ?
#include <iostream> using namespace std; int main() { std::cout << "Address of a main() function is : " <<&main<< std::endl; return 0; }
Pavel
#include <iostream> using namespace std; int main() { std::cout << "Address of a main() function is : " <<&main<< std::endl; return 0; }
This is UB in C++ as far as I know, because main is a "special" function and it can't be called or somehow used (e.g. to take address) in the code. https://github.com/shafik/cpp_undefined_behavior_enumerated/blob/master/all_section.md#basicstart
Anonymous
Is there a C++development program for writing game cheating programs? We can cooperate and make a lot of money
Suraj
Any one know about any free workshop on c++
Anonymous
How would i add it without typecasting it to int? And if i typecast it, it adds up it's ASCII values as Madhu said.
Why do you even need to convert the integer to the string. Just use the % and / operators tovget the individual digits and add them all up.
Marlo
Cout 12 numbers. From 1-12. Numbers which are division with 3 print start next to them. How can i do that? (C++)
Marlo
Print star next to them (*)
Holup
Do it yourselves 🙂
Unknown man
Can someone explain how to code of pascal triangle and how it works mean what the logic
Anonymous
Anyone that have new gpu? My budget is 100/130 eur in btc.If you have contact me! Only with escrow
Anonymous
what is reference on c++? i am struggling to find out what does it means
Pavel
what is reference on c++? i am struggling to find out what does it means
Reference is similar to a pointer, but - reference can't be nullptr - you can't reassign the address it points to, after it created - dereferencing happens automatically (you don't need to do (*myVal) to get the value, or myVal->foo to refer to a member, use myVal and myVal.foo instead)
P
Hello to all friends, Please guide me how I can switch from C language to C++ and write a program in Qt
Bigissue
Hi is there someone programming in qt c++?
Jose
Hello to all friends, Please guide me how I can switch from C language to C++ and write a program in Qt
There is no "easy way" to switch from an imperative language to a multiparadigm language
P
There is no "easy way" to switch from an imperative language to a multiparadigm language
So should I start learning from the beginning? Or am I considered an intermediate despite knowing the C language?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi guys! I'd like an advice: I have a server and many clients (at most, 100 clients) in my client-server application. What the app does: it's like a Facebook showcase, where people can post messages (obv it's a much simpler version!). So I want it to be as efficient as possible. Therefore, I came up with two solutions: 1) The server creates a main socket and sets it on listen. When a new connection is required, the server creates a client-reserved-socket, and a client-reserved-thread that will handle any action the client might take; 2) Without spawning a thread for each client, I create a client-reserved-socket, then wait for an action of the user. The code will use the select() function. Once a signal is perceived, the select() function will spawn a thread that will handle one task and one task only. So basically the thread is summoned whenever it's neede, does something and then it's killed by the machine. I like the second one more, as I've never used it and I'd like to try something new, but given the fact that my system expects in the worst case scenario 100 people posting stuff on the showcase and possibly a user may take the same action multiple times, I'm quite worried about the expenditure the creation of every thread will have. Yes, I know, a thread is quite easy to create and not so heavy to maintain, but consider this is done multiple times, possibly hundred of times! What do you think? Let me know! Thanks if you read this!
Dima
Hi guys! I'd like an advice: I have a server and many clients (at most, 100 clients) in my client-server application. What the app does: it's like a Facebook showcase, where people can post messages (obv it's a much simpler version!). So I want it to be as efficient as possible. Therefore, I came up with two solutions: 1) The server creates a main socket and sets it on listen. When a new connection is required, the server creates a client-reserved-socket, and a client-reserved-thread that will handle any action the client might take; 2) Without spawning a thread for each client, I create a client-reserved-socket, then wait for an action of the user. The code will use the select() function. Once a signal is perceived, the select() function will spawn a thread that will handle one task and one task only. So basically the thread is summoned whenever it's neede, does something and then it's killed by the machine. I like the second one more, as I've never used it and I'd like to try something new, but given the fact that my system expects in the worst case scenario 100 people posting stuff on the showcase and possibly a user may take the same action multiple times, I'm quite worried about the expenditure the creation of every thread will have. Yes, I know, a thread is quite easy to create and not so heavy to maintain, but consider this is done multiple times, possibly hundred of times! What do you think? Let me know! Thanks if you read this!
I know that will sound abstract, but use fibers/coroutines for connections and place all networking in it
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
I know that will sound abstract, but use fibers/coroutines for connections and place all networking in it
Thank you for your answer, but I don't know this stuff. It's a college project and we never talked about things like that. Are they ard to learn?
Dima
kinda, pseudo code: - Take X threads/cores to work on (I’ll take 8 ) - Create jobs (on fiber pool) - Dedicate one or two (shouldnt be much) threads for Queue processing. Talking about incoming connections - Dispatch connections to fibers (on another X threads)
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Aaaah ok, I get what you're saying
Dima
fibers on win32 api
Dima
my point is to take 1-2 threads (depends on your workload, probably one is enough) just to accept and dispatch connections
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Yea that could actually work, instead of leaving it to the main thread you say
Dima
just lock it, when accepting the incoming connections and process it queue-like that’s a good scheme
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
just lock it, when accepting the incoming connections and process it queue-like that’s a good scheme
Interesting idea, thanks for proposing it! I'll think about it, but I think I got your point, and it's valuable
Dima
this is how most of popular server(http,sockets) solutions would work excluding distributed load
Dima
in distributed workload all of that what I said before gets more complicated
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Well in fact it seems like a fast and reasonable solution to the problem; the ones I mentioned all suffer from some issue
Peter
Hello, is there a way to printf a function pointer? 🤔
Peter
Using ℅p specifier ?
no dice, it says " error: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘void (*)()’ [-Werror=format=] "
Pavel
no dice, it says " error: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘void (*)()’ [-Werror=format=] "
I think you need to pass pointer to the function pritnf("%p", &myFunc); something like this probably
Pavel
I get the same error message when I do that
https://wandbox.org/permlink/f0ODqA5Hr7etl8z8
Anonymous
#include<iostream> using namespace std; int *test() { static int x[4]; for(int i=0; i<4; i++) { x[i] = i%2; } return x; } int main() { int* arr = test(); printf("%d", *(arr+3)); return 0; }
Руслан
Anybody can tell me how it,s is 1
Arrays in C [0, 1, 2, 3] = 4 elements X[0] = 0, X[1] = 1, X[2] = 0, X[3] = 1 return X print arr[3]
Руслан
if i understand your code correctly
Anonymous
But bro here we have used Modulu operator %
Ольга
https://onlinegdb.com/uWJSUMywZ Good day, I don't understand why the value is not stored in my value using the constructor. I would be grateful for an explanation
\Device\NUL
The correct convention from array to pointer is from type ptr[x], to *(ptr + sizeof(type) * x)
Ольга
https://onlinegdb.com/uWJSUMywZ Good day, I don't understand why the value is not stored in my value using the constructor. I would be grateful for an explanation
#include <iostream> #include "Intnumber.h" using namespace std; Intnumber::Intnumber(int* p){ value= new(nothrow)int[1]; value[0]=p[0]; } void Intnumber::input() { cout<<value[0]; } Intnumber::~Intnumber(){ delete value; cout<<value; } This is code of construction
\Device\NUL
Arrays in C [0, 1, 2, 3] = 4 elements X[0] = 0, X[1] = 1, X[2] = 0, X[3] = 1 return X print arr[3]
Afaik, all static types are implicitly initialized to zero even you don't initialized it
Anton
Hi everyone. Does OCCF (orthodox canonical class form) imply that a class must not have other types of constructors? Example: class A { public: /* Standard OCCF */ A(); A(const A &); ~A(); A &operator=(const A &); /* Does following constructors considered to violate the canonical form? */ A(std::string); A(std::string, int); private: std::string x; int y; };
Void
char a[14]={"Wrong!","January","February","March","April","May","June","July","August","September","October","November","December"};
You know me
Void
a must be an 2d array
Thanks it works
Anonymous
🤔why
Because an array of chars is a string An array of strings is an array of arrays of chars