Operating System - Linux
1752468 Members
6315 Online
108788 Solutions
New Discussion юеВ

Re: 2D array C program in UNIX

 
SOLVED
Go to solution
Henry Chua
Super Advisor

2D array C program in UNIX

Hi Guys,

Is it possible to use 2D array in C for UNIX? I am using 10.20b, but it doesnt recognise my declaration. Can this be solved?

Best regards
Henry
8 REPLIES 8
Orhan Biyiklioglu
Respected Contributor
Solution

Re: 2D array C program in UNIX

Could you give a bit more details about the problem. How do you declare the 2D array.

int myarr[2][2];

works for me

Regards
Alessandro Pilati
Esteemed Contributor

Re: 2D array C program in UNIX

Henry,
post your output;
On my server, this declaration runs:
char city[3][6] = -"milan", "rome", "naples""";

Cheers,
Alex
if you don't try, you'll never know if you are able to
Stephen Keane
Honored Contributor

Re: 2D array C program in UNIX

Henry,

do you want to use a 2D array in shell, like you can do in C? If so, bad news, the standard shell doesn't support it. You could use Perl (which does) though.

Muthukumar_5
Honored Contributor

Re: 2D array C program in UNIX

I hope that is because of compiler problem. what is compiler version.

what `which cc`

what is your example program? post this information.

hth.
Easy to suggest when don't know about the problem!
TwoProc
Honored Contributor

Re: 2D array C program in UNIX

Henry,

2D arrays have been part of the C compiler a looong time, so I'm pretty sure you've got a syntax error. Can you post the suspect lines of code, along with the error?
We are the people our parents warned us about --Jimmy Buffett
A. Clay Stephenson
Acclaimed Contributor

Re: 2D array C program in UNIX

C can handle n-dimensional arrays of simple and complex types (e.g. structs) but since you don't bother to post your declaration, it's difficult to help you veryu much.
If it ain't broke, I can fix that.
Henry Chua
Super Advisor

Re: 2D array C program in UNIX

Hi guy, I made a mistake in my declaration.. I have figure it out.. sorry for the trouble!
Henry Chua
Super Advisor

Re: 2D array C program in UNIX

thanks!