Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-01-2003, 03:01 PM   #1
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Rep: Reputation: 15

sorry but this:

arr[] = i ;

it's right? arr[] what points? what's his meaning ?
Old 12-01-2003, 03:22 PM   #2
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Original Poster
Rep: Reputation: 15
that's to say, arr[] = i , put the content of i' variable in first element of arr?
Old 12-02-2003, 01:01 AM   #3
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 437

Rep: Reputation: 30
I'm not sure what you're asking. arr[] is obviously an array of some type, and i is presumed to be a variable of some type too, but you don't indicate what type of array arr is or why type of variable i is. If I had an array of integers, and a variable i that was an integer. I would do the following to put i at the first index of arr[]:

int main(){
    int i = 5;   /* an arbitrary value */
    int arr[10];   /* an array of 10 integers */
    arr[0] = i;    /* assign value i (which = 5) to the first index in arr[] */

   return 0;
I hope that helps.
Old 12-03-2003, 10:34 AM   #4
Registered: Jul 2003
Location: Bedford, UK
Distribution: Slackware 11.0, LFS 6.1
Posts: 519

Rep: Reputation: 30
If arr[] = i has a meaning, I don't know what it is. If you have an array arr[] then arr points to the beginning of the array, not arr[]. Similarly, if you are assigning values then you can say arr[n] = i, and also in the declaration you can say int arr[] = {i}, but not arr[] = i.
Old 12-03-2003, 11:41 AM   #5
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
arr[] = i is not valid c++ as far as i can work out, ive tried to do it by overloading the [] operator but it doesnt work because [] has to have one argument and it cant be a default argument
Old 12-05-2003, 09:06 AM   #6
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
It'd be useful to know what language is being talked about.

As kev said, it doesn't seem like valid C/C++. In C/C++ you would have a syntax like so:

int arr[] = {i, i2, i3, i4};

Your syntax reminds me somewhat of other languages I know, but none that have exactly that syntax...
Old 12-05-2003, 08:27 PM   #7
Registered: Jun 2003
Location: Toronto, Ontario, Canada
Posts: 288

Rep: Reputation: 30
Depends on the language, cause in php that would actually add an element to the array. It's cool, though you would need the stupid $ signs.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xorg, xsun, ARG!!!! linux-rulz Solaris / OpenSolaris 2 06-19-2005 06:47 AM
./configure... ARG! FireHawk321 Mandriva 6 11-22-2004 11:14 PM
Sendmail. Arg. iroxa Linux - Software 0 05-18-2004 07:17 PM
ls -al|grep <arg>|wc Pacemaker Linux - Software 1 04-24-2004 09:36 AM
arg Sleel Linux - Software 0 02-03-2002 12:53 AM

All times are GMT -5. The time now is 03:25 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration