klimi
Nameful
Is this your new favourite GIF?
klimi
klimi
Preparing the war axe is important
klimi
You need it to be sharp as axe
Dima
klimi
NXiss7
NXiss7
Nameful
Dima
Dima
be respectful, you came to this place asking OT questions, not c++ related
klimi
Rounak
klimi
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
What if argv is not even used? Can I carelessly reuse that area?
Nils
Also would it make /proc/self/cmdline unusable?
Luca
Luca
yay
Artöm
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
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
klimi
klimi
Techno
Oky thanks for help guys
Nils
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
Nils
Nils
After that part only pointer stuff is following, then program exits
NXiss7
Nils
Okay... So I'd just allocate more memory.
Nils
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 😅
Nils
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++
Nils