>actually works but why did they decide it was a good idea? It's not.
Always compile with -Wall -Wextra, preferrably with -pedantic as well.
Juan Scott
Thx didn't know about them.
Kevin Diaz
Were you born clinically retarded or were you lobotomized later on?
Gabriel Bailey
>it's ugly and confusing I have my complaints about pointers in C but what is your problem here? What else would you have wanted to happen here?
Sebastian Clark
how is that confusing? how is that inconsistent? what output did you expect? explain, we can't guess what you think
Jordan Lee
What were you expecting, exactly?
Isaac Allen
And -std=c89
Michael Adams
c11 is a thing, grandpa
Tyler Morales
He was expecting a compiler error, because he falsely assumed that C is a strongly typed language.
Ayden Nguyen
Brainlet here. What's wrong with this? You assign just a pointer to a new pointer variable, rite?
Carter Barnes
>Brainlet here. What's wrong with this? p is unassigned. q is assigned garbage.
Christian Parker
Use the notation char* p = q;
Caleb Hernandez
I don't see any type violation there
Brayden Bailey
Sure, I'll explain. If p,q are pointers then it makes sense to write p=q;. *p=q; on the other hand would be wrong because p is not pointing to any object yet and q is a pointer. But char *p=q; is correct. You see how in one instance *p=q is nonsense, as it should be, and in another *p=q isn't.
Asher Lopez
>use this wrong notation get out
Lincoln Taylor
o-o-o-okay then i understood this. Maybe OP is the brainlet then
Josiah Bennett
now answer this
Jackson Cruz
funny way to spell c99
Zachary Carter
For what reason? It makes char* p, q; even more confusing. Only the fist is a pointer.
Eli Richardson
Is
int a; int b=a;
Also a problem? OK I see. Well what you've got there is the same symbol having different meanings. It's not unusual.
Benjamin Allen
You're declaring q as a pointer to a char and assigning it the value of p, which is a pointer to a char. I don't see the issue here. You can use char* instead if that satisfies your autism.
Jack Anderson
Don't declare two variables on the same line then. Or C could just stop being a shit language, but we know that won't happen.
Samuel White
read the Spiral rule on C FAQ for reading C types also C types are written as you access it, there is kind of a duality in it
char *p could mean `p` is pointer to char but also char value accessed through pointer
int *(*transform)(int) could mean `transform` is a pointer to a function passing an int returning int but it could also read as int accessed through calling a function passing an int
just don't get confused, there are bazillion of people complaining on C pointer syntax and that Pascal did it better, but it just werks for 40 years
Alexander Bennett
>You can use char* instead if that satisfies your autism. OP again. I get what you mean now. I'll probably do it in this case.
David Nguyen
>Is .... Also a problem? Yes, see
Juan Ward
Noted. Thx for the explanation.
Hudson Brown
So you'd want this to be an error instead of a widely available warning? Why? It's potentially the case that the code is valid still. The problem is when you perform operations on or produce side effects with undefined values.