LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



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

Rep: Reputation: 15
arg[]


sorry but this:

arr[] = i ;

it's right? arr[] what points? what's his meaning ?
 
Old 12-01-2003, 04:22 PM   #2
linuxanswer
Member
 
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, 02:01 AM   #3
oulevon
Member
 
Registered: Feb 2001
Location: Boston, USA
Distribution: Slackware
Posts: 435

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[]:
Code:

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, 11:34 AM   #4
vasudevadas
Member
 
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, 12:41 PM   #5
kev82
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, 10:06 AM   #6
deiussum
Member
 
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, 09:27 PM   #7
coolman0stress
Member
 
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.
 
  


Reply


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 07:47 AM
./configure... ARG! FireHawk321 Mandriva 6 11-23-2004 12:14 AM
Sendmail. Arg. iroxa Linux - Software 0 05-18-2004 08:17 PM
ls -al|grep <arg>|wc Pacemaker Linux - Software 1 04-24-2004 10:36 AM
arg Sleel Linux - Software 0 02-03-2002 01:53 AM


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

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