variable-declaration

Why does this C code compile?

浪子不回头ぞ 提交于 2021-02-07 11:18:44
问题 #include <stdio.h> int main() { int c = c; printf("c is %i\n", c); return 0; } I'm defining an integer variable called c , and I'm assigning its value to itself. But how can this even compile? c hasn't been initialized, so how can its value be assigned to itself? When I run the program, I get c is 0 . I am assuming that the compiler is generating assembly code that is assigning space for the the c variable (when the compiler encounters the int c statement). Then it takes whatever junk value

Why does this C code compile?

房东的猫 提交于 2021-02-07 11:18:16
问题 #include <stdio.h> int main() { int c = c; printf("c is %i\n", c); return 0; } I'm defining an integer variable called c , and I'm assigning its value to itself. But how can this even compile? c hasn't been initialized, so how can its value be assigned to itself? When I run the program, I get c is 0 . I am assuming that the compiler is generating assembly code that is assigning space for the the c variable (when the compiler encounters the int c statement). Then it takes whatever junk value

What are some reasons to use var instead of let in javascript? [duplicate]

橙三吉。 提交于 2021-01-27 04:01:00
问题 This question already has answers here : What's the difference between using “let” and “var”? (38 answers) Closed 4 years ago . With the new keyword let for declaration of variables in javascript ES6, I can no longer think of good reasons to use var . So far, I have been doing just that and I do not see any disadvantage of using let ALL THE TIME. What are good reasons to use var today? Is it a good practice to use let all the time today? 回答1: IMO there is no definite advantage of using var

What are some reasons to use var instead of let in javascript? [duplicate]

倾然丶 夕夏残阳落幕 提交于 2021-01-27 04:00:35
问题 This question already has answers here : What's the difference between using “let” and “var”? (38 answers) Closed 4 years ago . With the new keyword let for declaration of variables in javascript ES6, I can no longer think of good reasons to use var . So far, I have been doing just that and I do not see any disadvantage of using let ALL THE TIME. What are good reasons to use var today? Is it a good practice to use let all the time today? 回答1: IMO there is no definite advantage of using var

Excel-VBA: Variable declaration necessary?

泄露秘密 提交于 2020-08-25 04:29:47
问题 Would it be wrong if write the following code Sub Something() Dim i As integer Dim xRange As Range Dim yRange As Range Set xRange= Range("x_table") Set yRange= Range("y_table") For i = 1 To xRange.Columns.Count xRange.Columns(i) = Application.Sum(y_table.Columns(i)) Next i End Sub without specifically declaring each of the variables? Like bellow; Sub Something() Set xRange= Range("x_table") Set yRange= Range("y_table") For i = 1 To xRange.Columns.Count xRange.Columns(i) = Application.Sum(y

Why do some variables declared using let inside a function become available in another function, while others result in a reference error?

杀马特。学长 韩版系。学妹 提交于 2020-01-30 13:52:31
问题 I can't understand why variables act so strange when declared inside a function. Example: function first() { let a = b = c = 10; var d = 20; second(); } function second() { alert(b + ", " + c); //shows "10, 10" alert(a); //reference error alert(d); //reference error } 回答1: It's because you're actually saying: c = 10; b = c; let a = b; And not what you think you are saying, which is: let a = 10; let b = 10; let c = 10; You'll notice that no matter how many variables you add to your chain, it

MYSQL Stored Procedures: Variable Declaration and Conditional Statements

Deadly 提交于 2020-01-11 18:55:04
问题 I have looked over numerous tutorials, manuals and documentations, but I still can not get this to work. I am trying to create a stored procedure using phpMyAdmin. I cant seem to find the errors here, the sql errors are so vague... CREATE PROCEDURE insertToonOneShot(IN locale CHAR(2), IN name VARCHAR(16), IN realm VARCHAR(24), IN faction CHAR(1), IN toon_level INT, IN class_name INT) BEGIN DECLARE @realmID INT; DECLARE @classID INT; DECLARE @toonID INT; SET @realmID = SELECT id FROM realms

MYSQL Stored Procedures: Variable Declaration and Conditional Statements

我是研究僧i 提交于 2020-01-11 18:53:23
问题 I have looked over numerous tutorials, manuals and documentations, but I still can not get this to work. I am trying to create a stored procedure using phpMyAdmin. I cant seem to find the errors here, the sql errors are so vague... CREATE PROCEDURE insertToonOneShot(IN locale CHAR(2), IN name VARCHAR(16), IN realm VARCHAR(24), IN faction CHAR(1), IN toon_level INT, IN class_name INT) BEGIN DECLARE @realmID INT; DECLARE @classID INT; DECLARE @toonID INT; SET @realmID = SELECT id FROM realms

Using the letter L in long variable declaration

隐身守侯 提交于 2020-01-10 03:57:25
问题 long l2 = 32; When I use the above statement, I don't get an error (I did not used l at the end), but when I use the below statement, I get this error: The literal 3244444444 of type int is out of range long l2 = 3244444444; If I use long l2 = 3244444444l; , then there's no error. What is the reason for this? Using l is not mandatory for long variables. 回答1: 3244444444 is interpreted as a literal integer but can't fit in a 32-bit int variable. It needs to be a literal long value , so it needs