Christian
Hello, just wondering if anyone has used this library in Windows to create Telegram bots. The library is 'Libtelegram' by user slowriot on Github.
Maxim
Hi! You can fix that just initialising the static variable outside the class: int MyObj::j = 0; or you can initialise the variable inside the class, but it should be const: static const int j = 0; Honestly, at this point I don’t understand why it doesn’t work, but seemly the compiler does not generate the initialisation code itself, so the linker does not find it
Maxim
I don’t think that this is a compiler problem. You have to initialise static variable at this case. I have tried it using g++ 12.2.1
devengine
Hi, what does that mean?
Thadeu
Me too... 5 months. Hope you love it like I'm doing :)
devengine
O ok
Maxim
Glad to hear it!
Ehsan
#cppbook
Ehsan
#help
Ehsan
#notes
Delicious
Which notes
Ehsan
#cppbooks
Ehsan
😂😂😂😂
Delicious
Text me
Delicious
Then I will send you
Delicious
Anyone need handwritten note for programming then text me.
Ehsan
C gives you superpowers without restrains
Delicious
In this group no media share
Ehsan
Python is more of a scripting language
Yeerriinn_
hello everyone, i have a question regarding c program. I have to build a vigenere cipher to decode and encode a given text. It works well but it doesn't ignore space. For my case, it convert space to M. Anyone know how to fix this?
Yeerriinn_
yeah but how can i do it?
\Device\NUL
yeah but how can i do it?
if (ch == ' ')
Tute
if (ch == ' ')
if(isspace(ch)) // include <ctype.h> first
\Device\NUL
if(isspace(ch)) // include <ctype.h> first
Don't forget to cast to unsigned
Chat Boss
Yeerriinn_ sent a huge message, it has been re-uploaded as a file getchar(); printf("\n Enter the plaintext (maximum 128 characters): "); gets(plain); printf("\n Enter the key (maxim..
Anonymous
I keep getting an error of stream undefined
Chat Boss
M O H I T K U M ∆ R sent a code, it has been re-uploaded as a file
M O H I T
Anonymous
What error?
After using of stream and compiling the program
Anonymous
I get the stream undefined error
Anonymous
can anybody help me to solve the problem?
The friend function declaration inside the classes A and B are different from the definition outside. Change the declaration inside class A and B to friend void fr(A,B)
Anonymous
Anonymous
Fstream
Then add a #include <fstream> to the list of includes. And make sure that you refer to it as std::fstream
p
Fstream
Can you send the code?
Anonymous
What is std::fstream? There are ifstream and ofstream
https://en.cppreference.com/w/cpp/io/basic_fstream fstream is an alias for basic_fstream<char>. Can be used for both input and output.
Anonymous
Is it possible to bring a class attribute to a function ?
Anonymous
generateMale(User.getAge());
Anonymous
i tried that but it doesnt work it just generates a random number
Constantine
นะวู
When Jojo was a child, his teacher asked him, What is the answer to 1^2+2^2+3^2+... N^2 ? Of course the problem is quite difficult for elementary school students. But since he was a university student, and he knew that the answer was 1/6 N (N + 1) (2 N+1), such a question was very easy for him. Now Jojo found a new problem. If he has an integer M, what is the smallest integer N such that 1^2+2^2+3^2 + ... + N^2 is greater than or equal to M. After thinking for some time, he came up with a solution, but the solution takes a lot of time. Since you are his nemesis, he challenges you to solve the problem faster than he does. Of course you take up the challenge! Format Input The first line is an integer T representing the number of test cases. For each test case, there will be 1 row consisting of an integer M. Output Format For each test case the output is "Case #X: N". X is the test case number (starting at 1) and N is the smallest integer such that 1^2+2^2+3^2+...+N^2 is greater than or equal to M. Constraints 1<=T<=2000 1<=M<=10^18 Sample Input 1 (standard input) 1 2 Sample Output 1 (standard output) Case #1: 2 Sample Input 2 (standard input) 1 10 Sample Output 2 (standard output) Case #1: 3
Jose
www.godbolt.org and start practice!
นะวู
Can anybody help me pleas ewhy my code is timelimit
Chat Boss
Can anybody help me pleas ewhy my code is timelimit
Naucea 564 sent a code, it has been re-uploaded as a file
Jose
Can anybody help me pleas ewhy my code is timelimit
I support you: You can do it! Come on!
Xxxx
Hey guys. So i have this assignment and I don’t want the solution, i just need some clarification. If u could help me just to understand the question that would be great. Thank you. An electronic store wants to keep an inventory of the products in its store. You are asked to write a program that asks the user to enter the brand (string, eg. Elba), serial number (string, eg. ELB102), type (string, eg. kettle), warranty period (int) and the price (double) for each product. The user can enter as many product’s information as needed (use a loop of your choice). The program should do the following : 1. Identify the total and average price of all products in the inventory. 2. Display the brand and model of the most expensive product. 3. How many kettles are in the inventory?
\Device\NUL
https://godbolt.org/z/v9GsTYKP4 Why MSVC generate lea r8d, QWORD PTR [r9 + 14] and not mov r8d, 14 ?
Xxxx
It’s my first assignment and I don’t know even where to start.
\Device\NUL
https://godbolt.org/z/v9GsTYKP4 Why MSVC generate lea r8d, QWORD PTR [r9 + 14] and not mov r8d, 14 ?
Okay, seems like lea r8d, QWORD PTR [r9 + 14] is much lighter than mov r8d, 14
Jose
https://godbolt.org/z/v9GsTYKP4 Why MSVC generate lea r8d, QWORD PTR [r9 + 14] and not mov r8d, 14 ?
Because when you xor x9r with itself, in x9r the value will be 0, the LEA approach is used in a multicore processor with various threads per core and/or pipelined processor (i don't remember which one). The probability of using the mov instruction in several threads will be higher than use LEA, and the pipelining of the CPU will take an optimization for this
ÊŘFÆŅ
Did you know a little point about c++?
ÊŘFÆŅ
You can work very easily in space x and program their rockets .
ÊŘFÆŅ
Or if you are still a student, you can start the Olympiad of computer.
Sasha
It’s my first assignment and I don’t know even where to start.
Start with designing an interface for the user. For example, you can imagine a CLI command that asks user to enter product details, and then when user is done, it will calculate the desired questions. So it may look like this: # compile program > gcc -o program main.cpp # run program > ./program Do you want to add a new product? y/n y Brand: elab S/number: ELB102 Type: kettle Warranty: 2 Price: 123 elab kettle with s/no ELB102, warranty period 2 for price 123 has been added Do you want to add a new product? y/n n You have added 1 product(s). Total price of added products is 123 ...and so on
Jose
Is that because lea r8d, QWORD PTR [r9 + 14] opcode is shorter than mov r8d, 14 ?
It depends, mainly when the linker adjusts the address where it will be. https://imgur.com/a/E8o59GO If you check the image, the mov instruction could have various lengths, depending on the "real" actuation of mov. lea instruction, on the other hand, lets the processor execute it in parallel (using the inners of shift and add instead of copying)
Ammar
It depends, mainly when the linker adjusts the address where it will be. https://imgur.com/a/E8o59GO If you check the image, the mov instruction could have various lengths, depending on the "real" actuation of mov. lea instruction, on the other hand, lets the processor execute it in parallel (using the inners of shift and add instead of copying)
There is no relevance with "linker adjusts the address" in this case. The r8d register shown by the poster is an immediate value, not an address of a variable. The linker doesn't touch its operand at all. The only reasonable answer for that is because: 45 8d 41 0e lea r8d, [r9 + 14] is shorter than: 41 b8 0e 00 00 00 mov r8d, 14 The instruction lea r8d, [r9 + 14] adds the r9 value as the dependency. Thus mov r8d, 14 is better for the pipeline parallelism because it doesn't have any data dependency on the previous instruction. That being said: xor r9d, r9d lea r8d, [r9 + 14] is heavier for the pipeline, because the lea depends on the xor. So the lea can't be executed before the xor finishes. If you have: xor r9d, r9d mov r8d, 14 those two instructions (xor and mov) can be executed in parallel because the mov doesn't depend on the previous instruction. If you increase the optimization level to O3, it will choose mov over lea. See: https://godbolt.org/z/o85v97KoP
Ammar
A summary of the excellent links in the comments: -O2 is often preferred over higher optimizations levels due to: · smaller generated code size (often equates to better performance because of processor caches for branch prediction) · less compilation time · bugs (in your code) which are more prone to be exposed in a higher optimization level. Link: https://stackoverflow.com/questions/35840775/whats-wrong-with-o3-optimization-level-3
I agree with these. But your previous reasoning: "lea instruction, on the other hand, lets the processor execute it in parallel" is not the case here. It's just an immediate value. The compiler generates lea over mov in the question is because it prefers smaller code size than higher performance (that generates bigger code) in that context.
\Device\NUL
Ammar
Oh, it doesn't have /O3 flag.