Nameful
Is this your new favourite GIF?
klimi
Preparing the war axe is important
klimi
You need it to be sharp as axe
Dima
klimi
Thats the other way
NXiss7
😂😂😂😂😂
Nameful
Rounak
you could read the rules and understand that we don’t like camera photos of a screen
Rules should be any kind of picture is not allowed... Only screenshot is allowed... But only it was written pic of code is not allowed...so i didn't understood that part... Bcz rules are not clear... But before that only... Admin is talking so rudely...
Dima
be respectful, you came to this place asking OT questions, not c++ related
Rounak
Okay new rule, No photos from you
Ok only screenshots👌😊
klimi
Where is the mute function
klimi
Here you go
Luca
hi guys
Dima
Welcome
Luca
int ricerca(int v1[], int v2[], bool sono_uguali, int n) { int i; for (int i = 0; i < n; ++i) { sono_uguali = sono_uguali && (v1[i] == v2[i]); } return sono_uguali; /* while(i<n && sono_uguali) { if(v1[i]!=v2[i]) { sono_uguali=false; } i++; } return sono_uguali;*/ } int main() { int ar1[MAX], ar2[MAX], num; bool flag; int i=0; printf("Inserire il numero di elementi\n"); scanf("%d", &num); for(i=0; i<num; i++) { printf("Inserire ar1\n"); scanf("%d", &ar1[i]); } for(i=0; i<num; i++) { printf("Inserire ar2\n"); scanf("%d", &ar2[i]); } ricerca(ar1, ar2, flag, num); if (flag) { printf("i valori corrispondono\n"); }else { printf("I valori non corrispondono\n"); } return 0; } that's the code, these are the errors: p210n17.c: In function ‘main’: p210n17.c:46:11: warning: passing argument 1 of ‘ricerca’ makes pointer from integer without a cast [-Wint-conversion] ricerca(ar1[i], ar2[i], flag, num); ^~~ p210n17.c:6:5: note: expected ‘int *’ but argument is of type ‘int’ int ricerca(int v1[MAX], int v2[MAX], bool flag, int n) ^~~~~~~ p210n17.c:46:19: warning: passing argument 2 of ‘ricerca’ makes pointer from integer without a cast [-Wint-conversion] ricerca(ar1[i], ar2[i], flag, num); ^~~ p210n17.c:6:5: note: expected ‘int *’ but argument is of type ‘int’ int ricerca(int v1[MAX], int v2[MAX], bool flag, int n) ^~~~~~~ what does it mean ç_ç
Luca
Basically i have to do a code where given 2 arrays i have to say with a boolean value if all the elements of the 2 arrays are equals or not.
Dima
int ricerca(int v1[], int v2[], bool sono_uguali, int n) { int i; for (int i = 0; i < n; ++i) { sono_uguali = sono_uguali && (v1[i] == v2[i]); } return sono_uguali; /* while(i<n && sono_uguali) { if(v1[i]!=v2[i]) { sono_uguali=false; } i++; } return sono_uguali;*/ } int main() { int ar1[MAX], ar2[MAX], num; bool flag; int i=0; printf("Inserire il numero di elementi\n"); scanf("%d", &num); for(i=0; i<num; i++) { printf("Inserire ar1\n"); scanf("%d", &ar1[i]); } for(i=0; i<num; i++) { printf("Inserire ar2\n"); scanf("%d", &ar2[i]); } ricerca(ar1, ar2, flag, num); if (flag) { printf("i valori corrispondono\n"); }else { printf("I valori non corrispondono\n"); } return 0; } that's the code, these are the errors: p210n17.c: In function ‘main’: p210n17.c:46:11: warning: passing argument 1 of ‘ricerca’ makes pointer from integer without a cast [-Wint-conversion] ricerca(ar1[i], ar2[i], flag, num); ^~~ p210n17.c:6:5: note: expected ‘int *’ but argument is of type ‘int’ int ricerca(int v1[MAX], int v2[MAX], bool flag, int n) ^~~~~~~ p210n17.c:46:19: warning: passing argument 2 of ‘ricerca’ makes pointer from integer without a cast [-Wint-conversion] ricerca(ar1[i], ar2[i], flag, num); ^~~ p210n17.c:6:5: note: expected ‘int *’ but argument is of type ‘int’ int ricerca(int v1[MAX], int v2[MAX], bool flag, int n) ^~~~~~~ what does it mean ç_ç
You are calling ricerca like (int, int) but function signature expects int[], int[]
Luca
oh
Luca
tryna fix
Luca
so how it would be?
Dima
I think you should replace this for(i=0; i<num; i++); { ricerca(ar1[i], ar2[i], flag, num); } by this: ricerca(ar1, ar2, flag, num);
Nils
Pointers are such a cool thing to mess with 😄
Wow, that bottom part is entirely reserved for argv...
Nils
What if argv is not even used? Can I carelessly reuse that area?
Nils
Also would it make /proc/self/cmdline unusable?
Luca
yay
Luca
now it's like it doesn't take the bool arg from the function wtf code: int ricerca(int v1[], int v2[], bool sono_uguali, int n); int main() { int ar1[MAX], ar2[MAX], num; bool flag=true; int i=0; printf("Inserire il numero di elementi\n"); scanf("%d", &num); for(i=0; i<num; i++) { printf("Inserire ar1\n"); scanf("%d", &ar1[i]); } for(i=0; i<num; i++) { printf("Inserire ar2\n"); scanf("%d", &ar2[i]); } ricerca(ar1, ar2, flag, num); if(!flag) { printf("I valori non corrispondono\n"); }else { printf("Tutti i valori corrispondono\n"); } return 0; } int ricerca(int v1[], int v2[], bool sono_uguali, int n) { int i=0; // int j=-1; int j=0; int s=0; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(v1[i]>v1[j]) { s=v1[i]; v1[i]=v1[j]; v1[j]=s; } } } j=0; for(i=0;i<n-1;i++) { for(j=i+1;j<n;j++) { if(v2[i]>v2[j]) { s=v2[i]; v2[i]=v2[j]; v2[j]=s; } } } for (int i = 0; i < n; i++) { if (v1[i] != v2[i]) { printf("entrato per %d volte \n", i); sono_uguali=false; } } return sono_uguali; }
Luca
when the program enters the last loop, it does the printf but the boolean value doesn't change, remaining on true ç_ç, so, when i go into the main it says that every value is equal even if not: it doesn't pass the boolean value. Already tried to declare the functions to boolean.
Arjun
NXiss7
What if argv is not even used? Can I carelessly reuse that area?
No, that area is usually allocated by calling process. Edit: args passed into the stack.
klimi
You spam indeed
klimi
We should have banned you right when you joined
Techno
How can we create the GUI in C program ?
Mar!o
Win32 api 😂
Techno
Can u share a tutorial or something for ref
Mar!o
Just google C win32 tutorial
Techno
Can't we use QT framework ?
Techno
Or GTK ?
Nils
Can't we use QT framework ?
Yes. Look at their webseite. They have exmaples
Techno
Oky thanks for help guys
NXiss7
So I can simply reuse it?
It's "read-only". That's what const before char* means.
Nils
It's "read-only". That's what const before char* means.
Hmm, I just tried and was able to successfully overwrite it with zeros
Nils
Overwriting with integer 1 works too. However it segfaults at the end because I have no idea how to check for the end of the allocation. 🤔
Nils
Can I somehow access that area as a variable that I can point my pointer to?
klimi
well
klimi
you have some function for alocating memory
Nils
Hmm, I could allocate additional memory but it does not look as clean to me.
NXiss7
Overwriting with integer 1 works too. However it segfaults at the end because I have no idea how to check for the end of the allocation. 🤔
Look, that is stack, you're writing data to your stack directly, without knowing sizes, that's a bad idea, you'll corrupt your memory.
Nils
After that part only pointer stuff is following, then program exits
NXiss7
Overwriting with integer 1 works too. However it segfaults at the end because I have no idea how to check for the end of the allocation. 🤔
You can't check it because args are "pushed" into stack. That's how things work.
Nils
Okay... So I'd just allocate more memory.
NXiss7
After that part only pointer stuff is following, then program exits
Stack size is limited, and you don't control it directly. When you create vars like "int a = 8" compiler pushes an sizeof(int) into stack.
Nils
What is it limited to?
NXiss7
If you're just playing around (which seems so) it's okay, I've done similiar things too, but just don't count on this coding style and read about memory management in C++.
Nils
Yeah I know 😅
klimi
do it with C
Nils
Why?
klimi
they are much closer languages
klimi
so you can convert branfuck -> C much very easy
Nils
Ah. But isn't C++ just an extension to C?
klimi
ye
klimi
but it has same security i think
NXiss7
What is it limited to?
It's influenced by lots of things, it's everything-dependent. But consider it as few KBs to be safe, few MBs at most including all low level sruff, args etc to be more precise.
klimi
also c++ is not good for c++