
Originally Posted by
**Seals**
Alright I figured it out. That pp[1] was a typo I did notice it but was lazy to edit the post again lol. And we needed a function that can reverse an array and return it. Ikr it didn't return shit there but it was just to test that it could work. Also here's the code
Code:
void PermbysVektor(int n)
{
int *pp = (int*)malloc(n*32);
for(int i = 0; i < n; i+=1)
{
int x;
printf("Vendosi nje numer qe doni te shtoni tek vektori:");
scanf("%d", &x);
pp[i] = x;
}
int *pp2 = (int*)malloc(n*32);
int l =0;
for(int i = (n-1),
f = 0; i >= 0,
f < n; i-= 1,
f += 1)
{
pp2[f] = pp[i];
}
system("pause");
}
As for the n*32, my brain was fucked and I forgot it's 32 bits not bytes. Alright I'm more of a .NET guy but still coding path is aaa really long piece of shit. Oh and I was in C and as far as I'm concerned there's was no "++" operator in C.
of course there is a ++ operator in C.
C Operator Reference
I mainly program with the C89 standard of C, and I recommend you learn how to properly program with C89 as well. Here's why: Even though it's a really old standard, it's the only real "portable" kind. Most mainstream compilers, (except Microsoft's compiler) support C99 and some C11, but if you want to compile for anything like embedded systems, you'll have to stick with the C89 compilers, since they are the only ones that exist. Not to mention, most C development these days are done in C89 anyway, so you better learn it.
I'm saying this, because your code isn't C89 compliant at all. It would generate dozens of errors, because C89 doesn't allow mixed declarations and statements in a block. A block is anything between a { and }. So, you'd have to declare everything you use first, at the beginning of the block, and then use it later. This includes for statements, you can't do for(int i = 0; ...), you'd have to declare i before.