variable-declaration

variable declaration within the while loop C/C++

霸气de小男生 提交于 2019-12-18 04:24:18
问题 according to me following while loop should be infinite but it runs only thrice main() { int i=3; while(i--) { int i=100; i--; printf("%d..",i); } } it outputs 99..99..99 but according to me it should run infinite times as every time control enters while loop it gets value 100.so it will never reach zero. just to experiment i replaced int i=100; with i=100; in side the while loop and now it runs infinite times..WHY??? 回答1: The variable i that checks the condition is the one you declared in

Why is no ReferenceError being thrown if a variable is used before it’s declared?

左心房为你撑大大i 提交于 2019-12-17 19:52:49
问题 I’m trying to wrap my head around the behavior of reference errors thrown in JavaScript. In the following example, a ReferenceError is thrown at the second line, and execution breaks: var obj = {}; obj.func1 = func2; alert('Completed'); Whereas in this example, the code completes successfully, though obj.func1 remains undefined : var obj = {}; obj.func1 = func2; var func2 = function() { alert('func2'); }; alert('Completed'); My assumption was that an error would be thrown at the second line

What is the difference between int* ptr and int *ptr in C? [duplicate]

白昼怎懂夜的黑 提交于 2019-12-17 19:39:10
问题 This question already has answers here : Difference between int* p and int *p declaration (4 answers) difference between int* i and int *i (8 answers) Closed 11 months ago . I am fairly new at C and I don't know the difference between the following two variable declarations: int* ptr; int *ptr; I think that in the declaration int* ptr; , ptr 's value cannot be changed whereas it can be changed for the declaration, int *ptr; I am not sure if that is it though. What is the concept behind the

Is it possible only to declare a variable without assigning any value in Python?

ぐ巨炮叔叔 提交于 2019-12-17 17:20:14
问题 Is it possible to declare a variable in Python, like so?: var so that it initialized to None? It seems like Python allows this, but as soon as you access it, it crashes. Is this possible? If not, why? EDIT: I want to do this for cases like this: value for index in sequence: if value == None and conditionMet: value = index break Duplicate Uninitialised value in python (by same author) Are there any declaration keywords in Python? (by the same author) Related Python: variable scope and function

Can I simultaneously declare and assign a variable in VBA?

帅比萌擦擦* 提交于 2019-12-17 10:25:32
问题 I'm new to VBA and want to know if I can convert the following declaration and assignment into one line: Dim clientToTest As String clientToTest = clientsToTest(i) or Dim clientString As Variant clientString = Split(clientToTest) 回答1: There is no shorthand in VBA unfortunately, The closest you will get is a purely visual thing using the : continuation character if you want it on one line for readability; Dim clientToTest As String: clientToTest = clientsToTest(i) Dim clientString As Variant:

Effect of declared and undeclared variables

百般思念 提交于 2019-12-17 06:09:31
问题 What is the major difference between JavaScript declared and undeclared variables, since the delete operator doesn't work on declared variables? var y = 43; // declares a new variable x = 42; delete x; // returns true (x is a property of the global object and can be deleted) delete y; // returns false (delete doesn't affect variable names) Why does this happen? Variables declared globally are also the properties of the window object, so why can't it be deleted? 回答1: Declared and undeclared

Effect of declared and undeclared variables

时光毁灭记忆、已成空白 提交于 2019-12-17 06:09:11
问题 What is the major difference between JavaScript declared and undeclared variables, since the delete operator doesn't work on declared variables? var y = 43; // declares a new variable x = 42; delete x; // returns true (x is a property of the global object and can be deleted) delete y; // returns false (delete doesn't affect variable names) Why does this happen? Variables declared globally are also the properties of the window object, so why can't it be deleted? 回答1: Declared and undeclared

i get an error when creating a variable and specifing the collation in sql server 2005

心不动则不痛 提交于 2019-12-16 18:04:31
问题 when i tried this: DECLARE @var nvarchar(500) collate Arabic_BIN i got that: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'collate'. that is the full code, it works, i do not know how but the person who give it to me have used it successfully CREATE FUNCTION fn_RemoveTashkeel (@InputString nvarchar(2300) ) RETURNS nvarchar(2300) AS BEGIN DECLARE @OutputString nvarchar(2300) COLLATE Arabic_BIN DECLARE @TashkeelChr char(8) COLLATE Arabic_BIN DECLARE @feed int SET

i get an error when creating a variable and specifing the collation in sql server 2005

强颜欢笑 提交于 2019-12-16 18:04:22
问题 when i tried this: DECLARE @var nvarchar(500) collate Arabic_BIN i got that: Msg 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword 'collate'. that is the full code, it works, i do not know how but the person who give it to me have used it successfully CREATE FUNCTION fn_RemoveTashkeel (@InputString nvarchar(2300) ) RETURNS nvarchar(2300) AS BEGIN DECLARE @OutputString nvarchar(2300) COLLATE Arabic_BIN DECLARE @TashkeelChr char(8) COLLATE Arabic_BIN DECLARE @feed int SET

Describe: int (*(*var[3])())(void (*)());

天涯浪子 提交于 2019-12-14 04:12:13
问题 int (*(*var[3])())(void (*)()); How would you describe the type of var in the above declaration? I get: Declares var as array of 3 pointers to functions (A) These functions (A) take any inputs and return a pointer to a function (B) These functions (B) take a pointer to a function (C) and return int These functions (C) take any inputs and return nothing Is this right? Thanks 回答1: Start with the leftmost identifier and work your way out, remembering that () and [] bind before * , so: T *a[N] //