digitalmars.D.bugs - Something wrong in integer array
- Hengky Hartono (13/13) Apr 21 2005 i am a new in D.
- zwang (3/22) Apr 21 2005 try this:
- Regan Heath (6/26) Apr 21 2005 I believe Walter plans in future to allow:
- Hengky Hartono (16/38) Apr 22 2005 thanx zwang. i can compile the code now.
- zwang (12/57) Apr 22 2005 There're several errors in your code:
- Hengky Hartono (1/1) Apr 22 2005 thank's zwang. I understand now.
i am a new in D. i am using dmd version 0.121 there is something wrong with this: int[] def = [ 1, 2, 3 ]; the compiler always give the error message: D:\HPORJECT\Dedicated\coba.d(4): variable coba.main.def is not a static and cannot have static initializer i have tried several ways in D, such as int[4] def=[1,2,3]; but it give me the same error message. i tried: int def[4]={1,2,3}; in D, but it give the same error, it works well in C++ not in D. i have read the document, but i can't found how to solve this. Help me please. There's always another option in every aspect of life.
Apr 21 2005
Hengky Hartono wrote:i am a new in D. i am using dmd version 0.121 there is something wrong with this: int[] def = [ 1, 2, 3 ]; the compiler always give the error message: D:\HPORJECT\Dedicated\coba.d(4): variable coba.main.def is not a static and cannot have static initializer i have tried several ways in D, such as int[4] def=[1,2,3]; but it give me the same error message. i tried: int def[4]={1,2,3}; in D, but it give the same error, it works well in C++ not in D. i have read the document, but i can't found how to solve this. Help me please. There's always another option in every aspect of life.try this: static int[] def = [1, 2, 3];
Apr 21 2005
On Thu, 21 Apr 2005 23:25:57 +0800, zwang <nehzgnaw gmail.com> wrote:Hengky Hartono wrote:I believe Walter plans in future to allow: int[] def = [1, 2, 3]; it's just not implemented yet. I have no idea why, but then, I'm not a compiler writer. Regani am a new in D. i am using dmd version 0.121 there is something wrong with this: int[] def = [ 1, 2, 3 ]; the compiler always give the error message: D:\HPORJECT\Dedicated\coba.d(4): variable coba.main.def is not a static and cannot have static initializer i have tried several ways in D, such as int[4] def=[1,2,3]; but it give me the same error message. i tried: int def[4]={1,2,3}; in D, but it give the same error, it works well in C++ not in D. i have read the document, but i can't found how to solve this. Help me please. There's always another option in every aspect of life.try this: static int[] def = [1, 2, 3];
Apr 21 2005
In article <d48gnk$7u1$1 digitaldaemon.com>, zwang says...Hengky Hartono wrote:thanx zwang. i can compile the code now. But it give me another error, when i want to see every value inside the array def. code: void main() { static int[] def = [ 1, 2, 3 ]; for(int i=0;i<(sizeof(def)/sizeof(int));i++) //loop for the length of array printf(array[i]); } the error: D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement ...up to 10 error like this.i am a new in D. i am using dmd version 0.121 there is something wrong with this: int[] def = [ 1, 2, 3 ]; the compiler always give the error message: D:\HPORJECT\Dedicated\coba.d(4): variable coba.main.def is not a static and cannot have static initializer i have tried several ways in D, such as int[4] def=[1,2,3]; but it give me the same error message. i tried: int def[4]={1,2,3}; in D, but it give the same error, it works well in C++ not in D. i have read the document, but i can't found how to solve this. Help me please. There's always another option in every aspect of life.try this: static int[] def = [1, 2, 3];
Apr 22 2005
Hengky Hartono wrote:In article <d48gnk$7u1$1 digitaldaemon.com>, zwang says...There're several errors in your code: 0. sizeof(x) is not supported by D. Use the .sizeof property instead. (See http://www.digitalmars.com/d/property.html) 1. (def.sizeof/int.sizeof) will always be 2 (8/4) no matter how many elements int[] def contains. Write def.length to get the number of elements. (See http://www.digitalmars.com/d/arrays.html) 2. "array" is not defined 3. the first argument of printf should be a string. Either write printf("%d", def[i]); or writef(def[i]); //remember to import std.stdio;Hengky Hartono wrote:thanx zwang. i can compile the code now. But it give me another error, when i want to see every value inside the array def. code: void main() { static int[] def = [ 1, 2, 3 ]; for(int i=0;i<(sizeof(def)/sizeof(int));i++) //loop for the length of array printf(array[i]); } the error: D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement D:\HPORJECT\Dedicated\coba.d(9): found 'EOF' instead of statement ...up to 10 error like this.i am a new in D. i am using dmd version 0.121 there is something wrong with this: int[] def = [ 1, 2, 3 ]; the compiler always give the error message: D:\HPORJECT\Dedicated\coba.d(4): variable coba.main.def is not a static and cannot have static initializer i have tried several ways in D, such as int[4] def=[1,2,3]; but it give me the same error message. i tried: int def[4]={1,2,3}; in D, but it give the same error, it works well in C++ not in D. i have read the document, but i can't found how to solve this. Help me please. There's always another option in every aspect of life.try this: static int[] def = [1, 2, 3];
Apr 22 2005