Thread: Two Dimentional array problems

  1. #16
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by stahta01 View Post
    Please post working code that initializes the same variable twice; then it will definitely be assignment.

    Tim S.
    I think your reading skills needs to be improved.

    Tim S.

    PS: I am adding you to my ignore list; since normally you seem to know what you are talking about. But, this thread shows you have major problem with certain areas of C knowledge. I need a reminder to ignore you because my knowledge level is not high enough to know when you are talking crap!
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by stahta01 View Post
    I think your reading skills needs to be improved.
    You want me to prove that an initialization can happen more than once. It doesn't. That's not what I claimed, so I'm not going to prove that you can initialize a variable twice. It is still an assignment.


    edit - Answer:
    a) What is the = operator called?
    b) How do the values get put into the variable at the time of initialization?
    c) What does that make initialization?


    Prove to me that assigning a value to a constant isn't an assignment. You can't. Because it is an assignment.
    Quote Originally Posted by stahta01 View Post
    I am adding you to my ignore list; since normally you seem to know what you are talking about. But, this thread shows you have major problem with certain areas of C knowledge. I need a reminder to ignore you because my knowledge level is not high enough to know when you are talking crap!
    I don't have a problem distinguishing between a random assignment scattered randomly in your code and an initialization. I know exactly what both are. Both are types of assignments.

    I'm right, you're wrong. So ignore me because you can't handle being wrong. I'm cool with that.


    Quzah.
    Last edited by quzah; 01-16-2012 at 12:04 PM.
    Hope is the first step on the road to disappointment.

  3. #18
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    You can argue it all you like, but initialisation is used for what can only be assigned at the point of declaration. The fact that it is not also dubbed an "assignment" is because assignment is distinguished by being something other than initialisation. The two intentionally don't overlap.
    I'm aware that you're more of a C person than a C++ person. The main reason for defining the terms this way may really go back to C++. In C++ code such as:
    Code:
    myClass x = 42;
    and
    Code:
    myClass x(42);
    both do not call the assignment operator at any point. Hence the reason that they are not called assignment. The first is simply different syntax for initialisation. This is just how it is. You can ignore common knowledge if you like, but that wont change it.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  4. #19
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by iMalc View Post
    You can argue it all you like, but initialisation is used for what can only be assigned at the point of declaration.
    I didn't say that wasn't true, now did I?
    Quote Originally Posted by iMalc View Post
    The fact that it is not also dubbed an "assignment" is because assignment is distinguished by being something other than initialisation. The two intentionally don't overlap.
    You're wrong. Assigning a value to a variable, regardless of when it happens, is an assignment. Assigning an initial value to something is called initialization. But it is in fact ASSIGNING an initial value.

    I noticed you went out of your way to intentionally avoid the questions I posed multiple times. Define initialization. You won't, because it proves you wrong.
    Quote Originally Posted by iMalc View Post
    I'm aware that you're more of a C person than a C++ person. The main reason for defining the terms this way may really go back to C++. In C++ code such as:
    Code:
    myClass x = 42;
    and
    Code:
    myClass x(42);
    both do not call the assignment operator at any point. Hence the reason that they are not called assignment. The first is simply different syntax for initialisation. This is just how it is. You can ignore common knowledge if you like, but that wont change it.
    They are both however actually assignments. That's what initialization is. That's why you won't define initialization for me when I've repeatedly asked you to, because it proves you wrong.

    You are wrong. Initialization is assigning an initial value. Period. You are wrong, I am not.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #20
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    It is actually the reverse of how you describe it, quzah.

    Section 6.5.16 of the C standard states (and I quote directly) "An assignment operator shall have a modifiable lvalue as its left operand". There is no such constraint placed on initializers, which is why they can act on other things (constants, rvalues, etc) but assignments cannot.

    The C standard Section 6.7.8 states that "An initializer specifies the initial value stored in an object". Nowhere in the standard is initialization defined in terms of assignment. Syntactically, an initialization expression may be composed of assignment expressions (which is why "int x = 5;" and "int x; x = 5;" have the same net effect if x is a variable) but the reverse is not true.

    By your logic, the expression "const int foo = 15;" is an assignment. According to the C standard it is not, because foo is not a modifiable lvalue. This expression is an initialisation, and cannot be separated into two expressions of the form "const int foo; foo = 15;". Why? Because initialisation is not a type of assignment.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #21
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If you can separate assignment in C, from "assigning" in English, then OK, I'll go with you, Grumpy.

    Personally, my mind isn't quite fractured enough to make that distinction Grumpy, so I have to agree with Quzah on this. The C standard may be the definitive C document, but here, they have crossed not only common usage of the word "assignment", but the definitive dictionary definition, as well.

    "The declaration may include an initial assignment of value, to the declared variable." That's how I think of it.

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by grumpy View Post
    By your logic, the expression "const int foo = 15;" is an assignment.
    Of course it's an assignment.

    You are describing the assignment operator's behavior as defined by the standard. You aren't defining what an assignment is.

    Quote Originally Posted by grumpy View Post
    According to the C standard it is not, because foo is not a modifiable lvalue. This expression is an initialisation, and cannot be separated into two expressions of the form "const int foo; foo = 15;". Why?
    It can't be separated into two different things, because then it wouldn't be initialization.
    Quote Originally Posted by grumpy View Post
    Because initialisation is not a type of assignment.
    Yes it is.
    5.1.2: All objects in static storage shall be initialized (set to their initial values).
    Those are all assignments. Putting a value in a variable is the act of assigning.
    6.2.4 (2): An object whose identifier is declared with external or internal linkage, or with the storage-class specifier static has static storage duration. For such an object, storage is reserved and its stored value is [u]initialized only once, prior to program startup[/i]
    That's another assignment.
    6.2.4 (4): For such an object that does not have a variable length array type, storage is guaranteed to be reserved for a new instance of the object one each entry into the block with which it is associated; the initial value of the object is indeterminate. If an initialization is specified for the object, it is performed each time the declaration is reached in the execution of the block;
    Guess what? THAT'S ANOTHER ASSIGNMENT!

    The function of the assignment operator is an indicator to YOU that an assignment IS HAPPENING. That's what it means. It doesn't matter what they do behind the scenes, that operator is telling you "Hey, an assignment is happening here."

    That's why we have an assignment operator. Every time you see it, you can say an assignment just happened. It doesn't matter if it happens when you launch the program and it only happens one time, or it happens a million times. Every time you see the assignment operator, C is telling you that something is being assigned.
    6.5.2.5 (2): No initializer shall attempt to provide a value for an object not contained within the entire unnamed object specified by the compound literal.
    Great, what does that have to do with anything? Oh, I know, it's saying that initializers proved a value to an object. What's the act of supplying a value for an object called?

    Wait for it...
    wait for it...
    assignment.

    Oh, I've got another one. Ready for this?
    6.7.8 Initialization
    Syntax
    Code:
    1 initializer:
        assignment-expression
        { initializer-list }
    Oh ****! What did that just say? ASSIGNMENT-EXPRESSION.

    Thanks for playing.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #23
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Adak, it has got nothing to do with fractured thinking. It is about identifying what document is a primary reference source and what is secondary in a technical discussion.

    The purpose of the C standard is to define the C language, and associated concepts necessary to understand and apply the C language. In a discussion of C, it is therefore necessary that participants accept that definitions in the C standard take precedence over the definitions of those terms (if any) in an english language dictionary. In other words, if the C standard is in conflict with the english language, then the C standard wins. In a discussion of C. Not in a social discourse about girls.

    This practice is true of any technical field, and many other fields of human endeavour.

    People who insist on doing the opposite just introduce unnecessary confusion and ambiguity into specific technical discussions. Which, frankly, is what quzah has done in this thread and you are defending. There is a fine line between that and trolling (which quzah's last post now strikes me as, so I will not be posting again in this thread).

    No question that the C standard is often difficult to understand, even for readers of the english language. However, lack of understanding of the C standard does not mean you should fall back on using an english-language dictionary, and disregard what the C standard says. Doing so, in whole or in part, negates the purpose of the standard. But that is exactly what you are advocating.
    Last edited by grumpy; 01-16-2012 at 06:04 PM.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  9. #24
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by grumpy View Post
    People who insist on doing the opposite just introduce unnecessary confusion and ambiguity into specific technical discussions. Which, frankly, is what quzah has done in this thread and you are defending. There is a fine line between that and trolling (which quzah's last post now strikes me as, so I will not be posting again in this thread).
    Of course you won't, because I just used the standard to prove to you that initialization is in fact assignment.

    The standard has a specific section to cover initialization. What do you think the "assignment-expression" portion of that segment means? Hmm?

    Quote Originally Posted by grumpy View Post
    No question that the C standard is often difficult to understand, even for readers of the english language. However, lack of understanding of the C standard does not mean you should fall back on using an english-language dictionary, and disregard what the C standard says. Doing so, in whole or in part, negates the purpose of the standard. But that is exactly what you are advocating.
    That part is not difficult to understand at all. Want me to run it by you again?
    6.7.8 Initialization
    Syntax:
    Code:
    1       initializer:
                assignment-expression
    Go read the entire section on Initialization. Every time you see the word "initializer", substitute it with "assignment-expression". Because that's what the C standard just told you it was.

    You lose. All of you.


    Quzah.
    Last edited by quzah; 01-16-2012 at 06:21 PM.
    Hope is the first step on the road to disappointment.

  10. #25
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    I am well aware (in fact I noted it in a previous post) that some initialisations may be composed of assignment-expressions. That does not mean that an initialisation is an assignment.

    "Composed of" is a distinct concept from "is". In the english language. In C. Even in object-oriented design. There may be some technical fields where "composed of" and "is" describe the same concepts, but the C programming language is not one of them.

    Trolls search for particular terms (in this case "assignment-expression") to support their specious arguments, which are made for the purpose of arguing and conveying their perceived sense of their own superiority, rather than providing information.

    That is why I am bowing out of this thread.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  11. #26
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by grumpy View Post
    I am well aware (in fact I noted it in a previous post) that some initialisations may be composed of assignment-expressions. That does not mean that an initialisation is an assignment.
    Of course it does.

    Any time you put a value into a variable, that's an assignment. The standard even says so. Let's go back to 6.5.16 again, shall we? Specifically, (3), semantics.
    An assignment operator stores a value in an object designated by the left hand side.
    Now back down to 6.7.8, specifically (wait for it...) (8), semantics.
    An initializer specifies the intital value stored in an object.
    What does THAT sound like?

    Quote Originally Posted by grumpy View Post
    Trolls search for particular terms (in this case "assignment-expression") to support their specious arguments, which are made for the purpose of arguing and conveying their perceived sense of their own superiority, rather than providing information.
    Do you want to know what else they do? They prove dumbasses wrong. Which of these sounds like you?

    a) Dumbass
    b) Wrong

    Hint: It's C.

    c) Both.

    Quote Originally Posted by grumpy View Post
    That is why I am bowing out of this thread.
    No, you're "bowing out" of this thread because you made a stupid statement, got proved wrong, tried to use the standard to make you not wrong, and got proved wrong again.

    This is one of those 3% times that you don't care about.


    Quzah.
    Hope is the first step on the road to disappointment.

  12. #27
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Well, I believe you were right about the assignment - can't see it any other way, but the name calling - that's a big fail. Grumpy has been very helpful in the forum, and is a smart and articulate guy. Even if he were a complete beginner, the name calling helps neither your argument nor the forum.

  13. #28
    Registered User VASHtheCHIBI's Avatar
    Join Date
    Jan 2012
    Location
    Hangzhou, China
    Posts
    14
    Well, this topic went from informative to a flame war overnight (for me at least. I'm assuming the rest of you are in the states). If quizah's persistence has done anything, it has encouraged people to post way more than I use to know about the assignments and initialization.

    Thanks for the help and the education.

    Is there a way to get a moderator to lock this thread?

  14. #29
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Adak View Post
    but the name calling - that's a big fail. Grumpy has been very helpful in the forum, and is a smart and articulate guy. Even if he were a complete beginner, the name calling helps neither your argument nor the forum.
    He called me a troll because he was losing an argument, I called him a dumbass. Seems fair.


    Quzah.
    Hope is the first step on the road to disappointment.

  15. #30
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    Yeah, this is done.
    IMO Quzah painted himself into a corner with some sloppy terminology right at the start and then tried to defend the indefensible.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer to two dimentional array
    By lio in forum C Programming
    Replies: 2
    Last Post: 11-06-2010, 10:55 AM
  2. 3 dimentional array in C
    By jahanpanah in forum C Programming
    Replies: 3
    Last Post: 10-24-2010, 11:16 AM
  3. 2 dimentional array
    By theone1 in forum C++ Programming
    Replies: 10
    Last Post: 11-11-2007, 01:30 PM
  4. Two dimentional array
    By h3ro in forum C++ Programming
    Replies: 12
    Last Post: 04-17-2007, 01:01 AM
  5. 2 dimentional array of pointers
    By Cerber4s in forum C++ Programming
    Replies: 1
    Last Post: 09-28-2003, 06:56 PM