Pavel
Yeah lol
So when you don't know at compile time how much memory you need, you can allocate that memory dynamically. In C you would use malloc for that to just get a piece of memory, in C++ you would use new that will also prepare the memory to be safely used with your type. Also there are things like unique_ptr which are even more safe, because whenever you allocate memory you need to free it, otherwise it will be hoarded by the app (leaked), and unique_ptr frees it for you. Have you learned pointers?
Pavel
If not, I suggest to first learn them, and for now just increase the number from 20 to something reasonable :D
Pavel
If you did, then the first answer https://stackoverflow.com/questions/4029870/how-to-create-a-dynamic-array-of-integers In reality the second answer with std::unique_ptr is better but std::vector is even more better in most of the cases
Divyanshi
Ok
Divyanshi
Thank you very much!!
labyrinth
Hi, I am stuck in using TSan, I am currently running gcc 7.5.0 and got ==2220888==FATAL: ThreadSanitizer: failed to intercept strlen, which I cannot find from google... anyone could help?
Unknown man
#include<stdio.h> int digitcheck(int,int); int main() { int num,digit; printf("Enter a number\n"); scanf("%d",&num); printf("Enter the digit\n"); scanf("%d",&digit); int z; int i; for(i=1;i<=3;i++) { z=digitcheck(num,digit); if(z==0) { printf("Our number has that digit on place %d",i); break; } else { num=num/10; } } return 0; } int digitcheck(int x,int y) { int z; z=x%y; return z; }
Unknown man
someone help i want to write a program to check a digit in number input
Unknown man
using function
G
using function
std::isdigit()
Ольга
Maybe someone knows how to pass a structure-pair to a function in C++? Will be grateful for any help
pavel
foo(pair<int, int> a)
Ольга
foo(pair<int, int> a)
Okey I'm trying. Thank you so much
Ольга
foo(pair<int, int> a)
I'm sorry. Maybe you know why in compiler I have error like:expected primary-expression before 'PAIR'?
Anonymous
write a program that checks whether the input is palindrome or not
Anonymous
in c++
Anonymous
🙏
Anonymous
Easy bro
i am a fresh student
Anonymous
can you get me the logic
Anonymous
according to my knowledge i should do that with the input number
Anonymous
cin>>num;
Anonymous
NUM%10;
Anonymous
WHAT do you think bro???
👾
Google it
👾
NUM%10;
Logic is correct It will give you remainder
👾
Then again Write a logic to get quotient
Anonymous
but it gives only reminder
👾
Using loop
Anonymous
And then repeat
it will give same reminder
👾
Bro google it
👾
You are fresher so it will be hard for me to tell you here
Anonymous
mens if i input 606 its stores 6 every time
Anonymous
okay
👾
it will give same reminder
Try this logic —— Int b , rev=0,remainder; // Using loop remainder = b%10; rev = (rev*10)+remainder; B = b/10; if(rev==num){ cout<<"it is a Palindrome Number";}
👾
if(rev == b) // it is correct . I used num instead of b
👾
why we divide it with 10
When we divide it with 10 we get quotient and when we use % operator we get remainder
👾
It’s Basic maths
Anonymous
after running i would be able to understand
👾
Don’t copy just see logic and try it your own … because I didn’t done it full i mean I didn’t wrote full and in proper way if you copy it will give error
Anonymous
i am usng the second logic of number dividing by 10
👾
U have to use both Eg:- m%10 m= m/10
Anonymous
bro what do you think is software engineering a good career
Anonymous
should i continue it or leave it
👾
😅
pavel
Take a paper and pencil and write an abstract algorithm without code
👾
Yes
Anonymous
Yes
should i continue it
pavel
should i continue it
Probably you shouldn't
👾
Bro if you are into it then u can in my opening almost every one is shifting to it industries
👾
Opinion*
Ольга
Show full code. Maybe you miss std namespace before pair
#include <iostream> #include <utility> using namespace std; int main() { pair<int, int>PAIR; void displayData(pair<int,int> PAIR); PAIR.first = 100; PAIR.second = 36; displayData(pair<int,int> PAIR); cout << PAIR.first << " "; cout << PAIR.second << endl; return 0; } void displayData(pair<int,int> PAIR) { cout << "\nDisplaying Information." << endl; cout << "Name: " << PAIR.first << endl; cout <<"Age: " << PAIR.second << endl; }
Anonymous
Opinion*
i have interest in programming but neighbours and parents ares forcing me to leave
Anonymous
they say theere are no jobs in this field
👾
Lol
👾
Really?? 😆
Ольга
And why pair in caps?
For no particular reason, but it's not good?
pavel
For no particular reason, but it's not good?
#include <iostream> #include <utility> using namespace std; void displayData(pair<int,int> PAIR) { cout << "\nDisplaying Information." << endl; cout << "Name: " << PAIR.first << endl; cout <<"Age: " << PAIR.second << endl; } int main() { pair<int, int>PAIR; PAIR.first = 100; PAIR.second = 36; cout << PAIR.first << " "; cout << PAIR.second << endl; displayData(PAIR); return 0; }
Deepak Chaurasia
Any video have any video lectures
Deepak Chaurasia
For learn cpp
pavel
For no particular reason, but it's not good?
It's ok, but don't make such names
Ольга
It's ok, but don't make such names
OK, I'll remember. Thank you very much for the answer, you really helped (and thanks for correcting the code, I finally understood what was wrong)
Prinzkyd
hello please can i get questions to solve
Prinzkyd
any please
Prinzkyd
i need questions to answer to practice
pavel
Implement SVD decomposition
𝟶𝚡𝟻𝟿
Hello, I'm finding trouble running any code on my vscode. Also, I'm seeing an error on Windows PowerShell saying it detected that I'm using a screen recorder and it disabled PSReadline, I don't know if that's what is affecting the vscode, how do I fix this please?
Deepak Chaurasia
/report crypto
Alireza
how can I use FindResource in c++??? it returns NULL every time !!why?
²
how can I use FindResource in c++??? it returns NULL every time !!why?
hmmmm... why... maybe because you using it incorrect ?