• C

very simple

Type TSortarray = array [ 1..10] of integer;

what's the equivalent in c?
Who is Participating?
940961slConnect With a Mentor Commented:
typedef int TSortArray[10];

void main(void)
   TSortArray              Array;

   Array[0] = 1;
typedef struct {int x[11];} TSORT;

      TSORT z;

      z.x[10] = 69;

      printf("equal %i",z.x[10]);
Thats not so very simple ... In c, array's start at 0 instead of 1.

typedef int TSortarray[10]

is the equivalent of

Type TSortarray = array [0 .. 9] of integer;

in your code.

You better learn to work with arrays that start with index 0, unless you want to do a lot of index translation, if you plan to program in C.

Hope this helps ...
Get Cisco Certified in IT Security

There’s a high demand for IT security experts and network administrators who can safeguard the data that individuals, corporations, and governments rely on every day. Pursue your B.S. in Network Operations and Security and gain the credentials you need for this high-growth field.

anemosAuthor Commented:
Adjusted points to 30
anemosAuthor Commented:
Thanks for your help... I am actually aware of the fact that the first array element is suscribted with 0. What I am wanting to know is whether it is possible to define a type int[n], where n is an integer, and then whenever I need to use an array of n elements just declare :
      type_array_10_elements   myvariable

 just like in pascal.

 thanks for your time.
anemosAuthor Commented:
moreover one has to remember that x (regarding the 1st answer) in order to use that type.
In C you usually do something like:

typedef double MyType;            /* or whatever you like best */
typedef struct { int a; double b; } MyType2;

MyType my_array_var[400];
MyType2 my_array_var[20];
i didn't write in c for a long time so i don't remember it exectlly

you can use something named macro

#define TSORT(x) int x [10]

int main(){

about the fact that the array start from 0
you can write a struct array
and make there some methods that will
make it looks that your array starts from x and goes till y
and you"ll use and index-x to transfer it to 0 to y-x

and you can use the maxcro on the struct
anemosAuthor Commented:
I am afraid that I can't use a macro... having some difficulties with the sise operator..
anemosAuthor Commented:
Exactly what I wanted.. Thanx all of you for your response and your time..
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.