Anupam2.7
Why there is str.at(n) function in c++ when we can simply using indexing i.e. str[n] ???
Anupam2.7
Thanks.
Dm
I have weird question. How to write multithreading txt file parser which can work faster then 1 thread version? I tried to do it in few ways but I see that processing speed sucks.
Dm
I use 1 thread to read and push to queue and in another thread I get front of the queue and parse but it still slower Something like 40%-50% lose.
Void
#include <stdio.h> #include <string.h> int main() { char a[20]; int len,i,upper,lower,num,sym; upper=lower=num=sym=0; scanf("%s",&a); len=strlen(a); for(i=0;i<=len;i++) { if(a[i]>='A'&&a[i]<='Z') { upper=1; } else if(a[i]>='a'&&a[i]<='z') { lower=1; } else if(a[i]>='0'&&a[i]<='9') { num=1; } else sym=1; } { int sum=upper+lower+num+sym; if(strlen(a)<6||sum==1) { printf("Not safe"); } if(sum==2) { printf("Medium Safe"); } else printf("Safe"); } return 0; }
Void
Guys why is sym=1 when I input 1234567
klimi
Guys why is sym=1 when I input 1234567
Because you set it to one in else sym=1
Void
Because you set it to one in else sym=1
😂I found the problem.I set i<len wrong
Kaptain
switch ("operator") { ERROR switch quantity not an integer
Ольга
Hello i need help with formula forFinding The difference areas of two rectangles when they intersect. Here is my version of the formula subtraction area=area1shape-area2shape+crosssectional area? It is correct?
klimi
meaning
You haven't put the correct thing into the switch
Anonymous
John
between char[] ,std::array<> and std:: vector<char> which one is better to use as packet buffer when handling socket in c++
Divyanshi
Anybody has any idea how to find square root of a number. I want to know the logic to code the program
Anonymous
between char[] ,std::array<> and std:: vector<char> which one is better to use as packet buffer when handling socket in c++
You should use either char [] or std::array<char, size>. Generally for buffers being passed across program boundaries, you should stick to types that are PODs and trivial. Vector is not though it has a standard layout. So you shouldn't use a vector.
X
I have some doubts
X
I am unable to include windows.h
X
in vscode and vs studio
X
any idea to fix this I thought about windows sdk ?
Constantine
Anybody has any idea how to find square root of a number. I want to know the logic to code the program
Try it: square root of x = to x^½, And x^n = exp(n * log(x)), so x^½ = exp(0.5 * log(x)). Perhaps it works🤕
Divyanshi
Ok Thanks!
Divyanshi
I don't think it's working....
Ludovic 'Archivist'
Anybody has any idea how to find square root of a number. I want to know the logic to code the program
Do an inverse square root and multiply your number by it. There are plenty of videos on the web that explain how to do a fast inverse square root
Ludovic 'Archivist'
(only works with IEEE754 as it is basically a trick to get an estimate of log(x) and then you use Newton's method to refine it)
Anónimo
Hello, I have a question. How can I make the program round a number of 2 decimals places from 5? For example, if the final number is 33.105, I want the program to show 33.11.
Dm
Hello everyone I would like to create function with template iterator (like this std::list<T>::iterator) but got was not declarated error (10 line) Could someone suggest solution ? https://godbolt.org/z/7eEchn7sK
Anonymous
Hello everyone I would like to create function with template iterator (like this std::list<T>::iterator) but got was not declarated error (10 line) Could someone suggest solution ? https://godbolt.org/z/7eEchn7sK
You have to define the overloaded printLists function (i.e. the one taking the iterators) before the printlLists function that takes two std::list arguments.
Anonymous
You have to define the overloaded printLists function (i.e. the one taking the iterators) before the printlLists function that takes two std::list arguments.
You also have to use typename before std::list<T>::iterator to tell the compiler that it is a typename. By default the compiler will assume that it is not a typename
Anonymous
why? if i delete templates everything works ok
That is how templates work. The problem is that with templates, when you call printLists with 4 arguments, it will see only the printLists with2 arguments and say that the arguments don't match. This is one of the errors that you got in GodBolt link that you sent The other errors are related to the missing typename keyword before the parameters in your overloaded function. typename std::list<T>::iterator l1_it and so on. This will inform the compiler that iterator is a typename and not some static value
Anonymous
It seems like I know nothing. where should I put typename std::list<T>::iterator l1_it? I can write you to PM if you don't mind
template<typename T> void printLists(typename std::list<T>::iterator& l1_it, const typename std::list<T>::iterator l1_it_end... and so on for the remaining 2 parameters
Omar
I hope someone can help
line 54: you have to assign an initial value to a stack variable that is Null lines: 58,59: you have to print the call of the sum function like : cout<<sum(stack); Lines: 13,26,37,45: you have to pass stack parameter by reference not by value because it is changed in your functions like : (node* &stack) in the definition of functions
Omar
Thank you very much for your help, you helped me a lot. I hope soon I understand this topic. Once again, thank you very much
Welcome my friend There are many ways to implement these instructions It's okay if you are at the beginning but just to learn that this code can be greatly improved 🌸🌸
Shahadat Shanto
WAP that will take (m x n) positive integer inputs into a matrix of dimension m x n. Now replace all the duplicate integers by -1 in that matrix
Shahadat Shanto
how to do this? any idea?
Shahadat Shanto
skip that part.
Daulet
Ok
Shahadat Shanto
for(int i=0; i<m; i++) { for(int j=0; j<n; j++) { if(arr[i] != arr[j]) { arr[i][j] = -1; } cout<<arr[i][j]<<" "; }
Shahadat Shanto
I've tried this
Shahadat Shanto
tell me
Daulet
Pass all values to std::set
Daulet
And search values from this set
Shahadat Shanto
ok
Anonymous
Anybody has any idea how to find square root of a number. I want to know the logic to code the program
If it's a perfect square, you can use binary search till half the number
Anupam2.7
https://pastebin.com/SCtXTXcA What is the use of function initcounter(void) in line 9 and what does { counter = 0;} means in line 9 after declaring the function initcounter(void) ?
ngdream
hi
Manish
Do anyone know how to do thread safe in C++ without using mutex and synchronisation??
Official hooligan of Pius XII
Do anyone know how to do thread safe in C++ without using mutex and synchronisation??
https://stackoverflow.com/questions/10770171/how-to-make-thread-synchronization-without-using-mutex-semorphore-spinlock-and
Fr
What is the best masterclasses to learn web development online?
Richard Luo 🐱
Is there any clangd alternative which uses gcc?
Richard Luo 🐱
Clangd is great but I encountered a lot of issues when using c++20.
Richard Luo 🐱
Daulet
Clangd is great but I encountered a lot of issues when using c++20.
What version you use? I have crash on 13 version, but in 14 all works well
Richard Luo 🐱
What version you use? I have crash on 13 version, but in 14 all works well
Neither of them worked. At least std::views does not work
Richard Luo 🐱
https://www.godbolt.org/z/Kze41jejo
Richard Luo 🐱
The code compiles with gcc, but clang or clangd cannot do it
Daulet
The code compiles with gcc, but clang or clangd cannot do it
That means you need to wait implementation of that features
Sajid
Is their any group discussion about opencv and deep learning in telegram?
Richard Luo 🐱
That means you need to wait implementation of that features
Why can't gcc develop a lsp when clang has clangd? I dont have to wait if there is gccd 😂
Anonymous
hi what can make 2 printf with the \n in there end show in the same line and how to fix it
Anonymous
```c
Anonymous
printf("grind size ([C]ourse,[F]ine): \r\n"); scanf("%c", &grind_size); if(*grind_size == 'C' 'c'){ Course = 1; Fine = 0; } else if(*grind_size == 'F' 'f'){ Course = 0; Fine = 1; } printf("Bag weight (g): ","\r\n"); scanf("%f", &Bag_weight); G = Bag_weight; gram= 453.5924; pound = 0.0022; Lbs = G * pound;
Anonymous
when it run it show in the same line
Anonymous
grind size ([C]ourse,[F]ine):Bag weight (g):
Rain Bow
#include <stdio.h> int main() { int length; int width; int Rectangle (length*width); printf("Enter the lenght : "); scanf("%d",&length); printf("Enter the width :"); scanf("%d",&width); printf("Total area : %d",&Rectangle); scanf("%d,%d",length,width); return 0; }
Rain Bow
Am using C/C++ compiler on mobile